Thread: [FOray-commit] SF.net SVN: foray: [10154] trunk/foray (Page 21)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-08-08 20:49:48
|
Revision: 10154
http://foray.svn.sourceforge.net/foray/?rev=10154&view=rev
Author: victormote
Date: 2007-08-08 13:49:50 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
Move the checkstyle task definition to the common script.
Modified Paths:
--------------
trunk/foray/foray-app/scripts/build.xml
trunk/foray/foray-areatree/scripts/build.xml
trunk/foray/foray-common/scripts/build.xml
trunk/foray/foray-core/scripts/build.xml
trunk/foray/foray-font/scripts/build.xml
trunk/foray/foray-fotree/scripts/build.xml
trunk/foray/foray-graphic/scripts/build.xml
trunk/foray/foray-hyphen/scripts/build.xml
trunk/foray/foray-layout/scripts/build.xml
trunk/foray/foray-mif/scripts/build.xml
trunk/foray/foray-output/scripts/build.xml
trunk/foray/foray-pdf/scripts/build.xml
trunk/foray/foray-pioneer/scripts/build.xml
trunk/foray/foray-pretty/scripts/build.xml
trunk/foray/foray-ps/scripts/build.xml
trunk/foray/foray-render/scripts/build.xml
trunk/foray/foray-speech/scripts/build.xml
trunk/foray/foray-text/scripts/build.xml
trunk/foray/scripts/build-common.xml
Modified: trunk/foray/foray-app/scripts/build.xml
===================================================================
--- trunk/foray/foray-app/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-app/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -171,14 +171,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-areatree/scripts/build.xml
===================================================================
--- trunk/foray/foray-areatree/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-areatree/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -131,14 +131,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-common/scripts/build.xml
===================================================================
--- trunk/foray/foray-common/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-common/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -128,14 +128,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-core/scripts/build.xml
===================================================================
--- trunk/foray/foray-core/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-core/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -124,14 +124,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-font/scripts/build.xml
===================================================================
--- trunk/foray/foray-font/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-font/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -194,14 +194,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-fotree/scripts/build.xml
===================================================================
--- trunk/foray/foray-fotree/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-fotree/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -139,14 +139,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-graphic/scripts/build.xml
===================================================================
--- trunk/foray/foray-graphic/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-graphic/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -136,14 +136,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-hyphen/scripts/build.xml
===================================================================
--- trunk/foray/foray-hyphen/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-hyphen/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -183,14 +183,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-layout/scripts/build.xml
===================================================================
--- trunk/foray/foray-layout/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-layout/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -121,14 +121,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-mif/scripts/build.xml
===================================================================
--- trunk/foray/foray-mif/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-mif/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -123,14 +123,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-output/scripts/build.xml
===================================================================
--- trunk/foray/foray-output/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-output/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -133,14 +133,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-pdf/scripts/build.xml
===================================================================
--- trunk/foray/foray-pdf/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-pdf/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -126,14 +126,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-pioneer/scripts/build.xml
===================================================================
--- trunk/foray/foray-pioneer/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-pioneer/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -125,14 +125,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-pretty/scripts/build.xml
===================================================================
--- trunk/foray/foray-pretty/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-pretty/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -124,14 +124,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-ps/scripts/build.xml
===================================================================
--- trunk/foray/foray-ps/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-ps/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -129,14 +129,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
Modified: trunk/foray/foray-render/scripts/build.xml
===================================================================
--- trunk/foray/foray-render/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-render/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -157,14 +157,6 @@
<!-- =================================================================== -->
<target name="style" depends="package-test" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-speech/scripts/build.xml
===================================================================
--- trunk/foray/foray-speech/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-speech/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -129,14 +129,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/foray-text/scripts/build.xml
===================================================================
--- trunk/foray/foray-text/scripts/build.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/foray-text/scripts/build.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -123,14 +123,6 @@
<!-- =================================================================== -->
<target name="style" depends="package" description="Runs checkstyle"
if="checkstyle.home">
- <taskdef name="checkstyle"
- classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
- <classpath>
- <fileset dir="${checkstyle.home}">
- <include name="checkstyle-all-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
<checkstyle config="../../scripts/checkstyle-config.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
Modified: trunk/foray/scripts/build-common.xml
===================================================================
--- trunk/foray/scripts/build-common.xml 2007-08-08 20:19:31 UTC (rev 10153)
+++ trunk/foray/scripts/build-common.xml 2007-08-08 20:49:50 UTC (rev 10154)
@@ -48,6 +48,15 @@
<include name="*.jar"/>
</fileset>
+ <taskdef name="checkstyle"
+ classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
+ <classpath>
+ <fileset dir="${checkstyle.home}">
+ <include name="checkstyle-all-*.jar"/>
+ </fileset>
+ </classpath>
+ </taskdef>
+
</target>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-08-09 01:52:47
|
Revision: 10156
http://foray.svn.sourceforge.net/foray/?rev=10156&view=rev
Author: victormote
Date: 2007-08-08 18:52:50 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
Stub in support for MathML.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
trunk/foray/resource/fo-examples/basic/images.fo
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/lib/jeuclid-core-2.9.8.jar
trunk/foray/lib/jeuclid-license.txt
trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-09 01:27:26 UTC (rev 10155)
+++ trunk/foray/foray-graphic/.classpath 2007-08-09 01:52:50 UTC (rev 10156)
@@ -27,5 +27,6 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-pdf-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-pdf-transcoder-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
+ <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-2.9.8.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-09 01:27:26 UTC (rev 10155)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-09 01:52:50 UTC (rev 10156)
@@ -37,6 +37,7 @@
import org.foray.graphic.factory.GIFFactory;
import org.foray.graphic.factory.GraphicFactory;
import org.foray.graphic.factory.JPEGFactory;
+import org.foray.graphic.factory.MathFactory;
import org.foray.graphic.factory.PDFFactory;
import org.foray.graphic.factory.PNGFactory;
import org.foray.graphic.factory.SVGFactory;
@@ -124,6 +125,7 @@
this.standardFactories.add(new PDFFactory(this));
this.standardFactories.add(new PNGFactory(this));
this.standardFactories.add(new TIFFFactory(this));
+ this.standardFactories.add(new MathFactory(this));
}
/**
Added: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2007-08-09 01:52:50 UTC (rev 10156)
@@ -0,0 +1,113 @@
+/*
+ * 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.factory;
+
+import net.sourceforge.jeuclid.MathBase;
+import net.sourceforge.jeuclid.MathMLParserSupport;
+import net.sourceforge.jeuclid.ParameterKey;
+import net.sourceforge.jeuclid.converter.Converter;
+
+import org.foray.graphic.FOrayGraphicServer;
+import org.foray.graphic.SVGGraphic;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Factory that tests the graphic to see if it is a MathML document, and creates
+ * an appropriate Graphic instance if it is.
+ */
+public class MathFactory extends GraphicFactory {
+
+ /** The number of bytes to read when testing whether a file is a MathML
+ * document. */
+ protected static final int SIG_LENGTH = 1024;
+
+ /**
+ * Constructor.
+ * @param server The parent graphic server.
+ */
+ public MathFactory(final FOrayGraphicServer server) {
+ super(server);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SVGGraphic attemptCreate(final URL url,
+ final BufferedInputStream bis) throws IOException {
+ final byte[] header = new byte[MathFactory.SIG_LENGTH];
+ bis.read(header);
+ /* For now, try to avoid parsing the whole document. Converting a byte
+ * array to a String is a bit risky & this may need some more work. */
+ final String headerString = new String(header);
+ final int mathStringIndex = headerString.indexOf("<math");
+ if (mathStringIndex < 0) {
+ return null;
+ }
+
+ /* Convert to an SVG and create an SVGGraphic instance. */
+ MathBase mathBase = null;
+ try {
+ final InputStream inputStream = url.openStream();
+ final Document xmlDocument =
+ MathMLParserSupport.parseInputStreamXML(inputStream);
+ final Map<ParameterKey, String> parameters =
+ new HashMap<ParameterKey, String>();
+ /* The actual mime-type is "image/svg+xml", but this is what works
+ * in the JEuclid code. */
+ parameters.put(ParameterKey.OutFileType,
+ net.sourceforge.jeuclid.Converter.TYPE_SVG);
+ mathBase = MathMLParserSupport.createMathBaseFromDocument(
+ xmlDocument, parameters);
+ } catch (final SAXException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ final Converter converter = Converter.getConverter();
+ converter.convert(mathBase.getRootElement(), outputStream,
+ mathBase.getParams());
+ final byte[] svgBytes = outputStream.toByteArray();
+ final ByteArrayInputStream inputStream = new ByteArrayInputStream(
+ svgBytes);
+ final BufferedInputStream svgBis = new BufferedInputStream(inputStream);
+ return new SVGGraphic(this.getServer(), url, svgBis);
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/lib/jeuclid-core-2.9.8.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/jeuclid-core-2.9.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/jeuclid-license.txt
===================================================================
--- trunk/foray/lib/jeuclid-license.txt (rev 0)
+++ trunk/foray/lib/jeuclid-license.txt 2007-08-09 01:52:50 UTC (rev 10156)
@@ -0,0 +1,202 @@
+
+ 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.
Property changes on: trunk/foray/lib/jeuclid-license.txt
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/resource/fo-examples/basic/images.fo
===================================================================
--- trunk/foray/resource/fo-examples/basic/images.fo 2007-08-09 01:27:26 UTC (rev 10155)
+++ trunk/foray/resource/fo-examples/basic/images.fo 2007-08-09 01:52:50 UTC (rev 10156)
@@ -221,4 +221,20 @@
</fo:flow>
</fo:page-sequence>
+<fo:page-sequence master-reference="psmOddEven">
+<fo:flow flow-name="xsl-region-body">
+
+ <fo:block
+ font-size="16pt"
+ font-weight="bold"
+ space-before.minimum="1em"
+ space-before.optimum="1.5em"
+ space-before.maximum="2em">A MathML Example</fo:block>
+ <fo:block>
+ <fo:external-graphic src="url('../graphics/mathml-example-1.xml')"/>
+ </fo:block>
+
+</fo:flow>
+</fo:page-sequence>
+
</fo:root>
Added: trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml
===================================================================
--- trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml (rev 0)
+++ trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml 2007-08-09 01:52:50 UTC (rev 10156)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE math
+ PUBLIC "-//W3C//DTD MathML 2.0//EN"
+ "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">
+
+<math mode="display">
+ <mrow>
+ <munderover>
+ <mo>∫</mo>
+ <mn>1</mn>
+ <mi>x</mi>
+ </munderover>
+ <mfrac>
+ <mi>dt</mi>
+ <mi>t</mi>
+ </mfrac>
+ </mrow>
+</math>
\ No newline at end of file
Property changes on: trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml
___________________________________________________________________
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-08-09 16:51:23
|
Revision: 10158
http://foray.svn.sourceforge.net/foray/?rev=10158&view=rev
Author: victormote
Date: 2007-08-09 09:51:25 -0700 (Thu, 09 Aug 2007)
Log Message:
-----------
Better handling of null graphics.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java 2007-08-09 16:49:16 UTC (rev 10157)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java 2007-08-09 16:51:25 UTC (rev 10158)
@@ -80,6 +80,10 @@
final ExternalGraphic generatedBy,
final GraftingPoint graftingPoint,
final int width) {
+ if (generatedBy.getGraphic(newEgArea) == null) {
+ throw new IllegalArgumentException("Cannot create an Area for a "
+ + "null Graphic.");
+ }
newEgArea.generatedBy = newEgArea.linkage(generatedBy, graftingPoint);
newEgArea.registerWithLinkage(graftingPoint);
final int initialPD = newEgArea.computeInitialPD();
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java 2007-08-09 16:49:16 UTC (rev 10157)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java 2007-08-09 16:51:25 UTC (rev 10158)
@@ -63,6 +63,11 @@
setProgress(0);
}
+ if (this.realFONode.getGraphic(areaNode) == null) {
+ this.getLogger().warn("Null graphic cannot be laid out."
+ + this.realFONode.getContextMessage());
+ return Status.OK;
+ }
final int height = this.realFONode.viewportBpd(areaNode);
if (areaNode.nearestArea().pdAvailable()
< height) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-08-09 20:48:05
|
Revision: 10162
http://foray.svn.sourceforge.net/foray/?rev=10162&view=rev
Author: victormote
Date: 2007-08-09 13:47:42 -0700 (Thu, 09 Aug 2007)
Log Message:
-----------
Minor doc or debugging changes.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2007-08-09 20:47:20 UTC (rev 10161)
+++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2007-08-09 20:47:42 UTC (rev 10162)
@@ -213,8 +213,8 @@
return fd;
}
}
- /* According to the spec, weight will never cause the failure of a
- * font-family to select a font.
+ /* According to the CSS2 Recommendation, Section 15.5, weight will never
+ * cause the failure of a font-family to select a font.
* In other words, getting the desired font-family is perceived to be
* more important than getting the right weight.
* So, since we failed to find a perfect match above, look for fonts
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-08-09 20:47:20 UTC (rev 10161)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-08-09 20:47:42 UTC (rev 10162)
@@ -4049,15 +4049,16 @@
firstChar = ' ';
}
final FontConsumer fontConsumer = this.getFontConsumer();
- resolvedFont = fontConsumer.selectFontXsl(
- this.traitFontSelectionStrategy(context),
- this.traitFontFamily(context),
- this.traitFontStyle(context),
- this.traitFontWeight(context),
- this.traitFontVariant(context),
- this.traitFontStretch(context),
- this.traitFontSize(context),
- firstChar);
+ final Font.SelectionStrategy strategy =
+ this.traitFontSelectionStrategy(context);
+ final String[] fontFamily = this.traitFontFamily(context);
+ final Font.Style style = this.traitFontStyle(context);
+ final Font.Weight weight = this.traitFontWeight(context);
+ final Font.Variant variant = this.traitFontVariant(context);
+ final Font.Stretch stretch = this.traitFontStretch(context);
+ final int size = this.traitFontSize(context);
+ resolvedFont = fontConsumer.selectFontXsl(strategy, fontFamily,
+ style, weight, variant, stretch, size, firstChar);
} catch (final FontException e) {
this.getLogger().error("Error creating Font.\n"
+ this.getContextMessage());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-08-10 19:20:10
|
Revision: 10167
http://foray.svn.sourceforge.net/foray/?rev=10167&view=rev
Author: victormote
Date: 2007-08-10 12:20:10 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
Improvements to JEuclid support. Can now process normally without errors. No output yet.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
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/factory/MathFactory.java
Added Paths:
-----------
trunk/foray/lib/batik-1.6-svggen.jar
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-10 19:18:27 UTC (rev 10166)
+++ trunk/foray/foray-graphic/.classpath 2007-08-10 19:20:10 UTC (rev 10167)
@@ -28,5 +28,6 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-pdf-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-pdf-transcoder-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
<classpathentry kind="lib" path="/FOray Lib/jeuclid-core-2.9.8.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svggen.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsConfiguration.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsConfiguration.java 2007-08-10 19:18:27 UTC (rev 10166)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsConfiguration.java 2007-08-10 19:20:10 UTC (rev 10167)
@@ -28,13 +28,13 @@
package org.foray.graphic.batik;
-import java.awt.Rectangle;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.Rectangle;
import java.awt.Transparency;
-import java.awt.image.ColorModel;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
/**
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java 2007-08-10 19:18:27 UTC (rev 10166)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java 2007-08-10 19:20:10 UTC (rev 10167)
@@ -28,9 +28,9 @@
package org.foray.graphic.batik;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsConfigTemplate;
/**
* This implements the GraphicsDevice interface as appropriate for
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2007-08-10 19:18:27 UTC (rev 10166)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2007-08-10 19:20:10 UTC (rev 10167)
@@ -30,23 +30,25 @@
import net.sourceforge.jeuclid.MathBase;
import net.sourceforge.jeuclid.MathMLParserSupport;
-import net.sourceforge.jeuclid.ParameterKey;
-import net.sourceforge.jeuclid.converter.Converter;
import org.foray.graphic.FOrayGraphicServer;
import org.foray.graphic.SVGGraphic;
+import org.axsl.graphic.GraphicException;
+
+import org.apache.batik.svggen.SVGGeneratorContext;
+import org.apache.batik.svggen.SVGGraphics2D;
+
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.svg.SVGDocument;
import org.xml.sax.SAXException;
+import java.awt.Dimension;
import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
/**
* Factory that tests the graphic to see if it is a MathML document, and creates
@@ -81,40 +83,74 @@
return null;
}
- /* TODO: The mathml-to-svg conversion below currently does not work, so
- * we return null here to avoid uglier problems downstream. Fix this
- * as we get more information from JEuclid. */
- if (1 == 1) {
- return null;
- }
-
/* Convert to an SVG and create an SVGGraphic instance. */
MathBase mathBase = null;
try {
final InputStream inputStream = url.openStream();
final Document xmlDocument =
MathMLParserSupport.parseInputStreamXML(inputStream);
- final Map<ParameterKey, String> parameters =
- new HashMap<ParameterKey, String>();
- /* The actual mime-type is "image/svg+xml", but this is what works
- * in the JEuclid code. */
- parameters.put(ParameterKey.OutFileType,
- net.sourceforge.jeuclid.Converter.TYPE_SVG);
mathBase = MathMLParserSupport.createMathBaseFromDocument(
- xmlDocument, parameters);
+ xmlDocument, MathBase.getDefaultParameters());
} catch (final SAXException e) {
throw new IOException(e.getMessage());
}
- final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- final Converter converter = Converter.getConverter();
- converter.convert(mathBase.getRootElement(), outputStream,
- mathBase.getParams());
- final byte[] svgBytes = outputStream.toByteArray();
- final ByteArrayInputStream inputStream = new ByteArrayInputStream(
- svgBytes);
- final BufferedInputStream svgBis = new BufferedInputStream(inputStream);
- return new SVGGraphic(this.getServer(), url, svgBis);
+ SVGDocument svgDocument = null;
+ try {
+ svgDocument = this.convertToSvg(mathBase);
+ } catch (final GraphicException e) {
+ throw new IOException(e.getMessage());
+ }
+ return new SVGGraphic(this.getServer(), svgDocument);
}
+ /**
+ * Converts a MathBase (JEuclid MathML document) instance to an SVGDocument.
+ * @param mathBase The JEuclid MathML document to be converted.
+ * @return The SVGDocument containing an SVG representation of the MathML
+ * document.
+ * @throws GraphicException For errors during conversion.
+ */
+ private SVGDocument convertToSvg(final MathBase mathBase)
+ throws GraphicException {
+ final SVGGraphics2D svgGenerator = this.createSVGGenerator(mathBase);
+ mathBase.paint(svgGenerator);
+ final Element svgRoot = svgGenerator.getRoot();
+ final Document svgDocument = svgRoot.getOwnerDocument();
+ if (svgDocument == null) {
+ throw new GraphicException("Error converting MathML to SVG: "
+ + "Document is null.");
+ }
+ if (! (svgDocument instanceof SVGDocument)) {
+ throw new GraphicException("Error converting MathML to SVG: "
+ + "Converted document is not SVG.");
+ }
+ return (SVGDocument) svgDocument;
+ }
+
+ /**
+ * Create a Batik SVG Generator for a given MathBase instance.
+ * NOTE: This method was copied verbatim from
+ * net.sourceforge.jeuclid.app.foprep.Processor#createSVGGenerator(MathBase)
+ * which is a private method, then modified to start with an SVGDocument
+ * instead of generic DOM Document.
+ * @param mathBase The JEuclid MathML document to be converted.
+ * @return The Batik SVG Generator.
+ * @throws GraphicException For error obtaining a new SVGDocument instance.
+ */
+ private SVGGraphics2D createSVGGenerator(final MathBase mathBase)
+ throws GraphicException {
+ final SVGDocument svgDocument = this.getServer().makeSvgDocument();
+ final SVGGeneratorContext svgContext = SVGGeneratorContext
+ .createDefault(svgDocument);
+ svgContext.setComment("Converted from MathML using JEuclid");
+ final SVGGraphics2D svgGenerator = new SVGGraphics2D(svgContext, true);
+
+ final Dimension size = new Dimension((int) Math.ceil(mathBase
+ .getWidth(svgGenerator)), (int) Math.ceil(mathBase
+ .getHeight(svgGenerator)));
+ svgGenerator.setSVGCanvasSize(size);
+ return svgGenerator;
+ }
+
}
Added: trunk/foray/lib/batik-1.6-svggen.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-svggen.jar
___________________________________________________________________
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-08-10 22:55:31
|
Revision: 10169
http://foray.svn.sourceforge.net/foray/?rev=10169&view=rev
Author: victormote
Date: 2007-08-10 15:55:26 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
Use the DOM Level 3 Load/Save features to parse the DOM.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-10 22:54:29 UTC (rev 10168)
+++ trunk/foray/foray-graphic/.classpath 2007-08-10 22:55:26 UTC (rev 10169)
@@ -27,7 +27,7 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-pdf-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-pdf-transcoder-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
- <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-2.9.8.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-2.9.8.jar" sourcepath="/FOray Lib-Build/jeuclid/jeuclid-core-2.9.8-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-svggen.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-10 22:54:29 UTC (rev 10168)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-10 22:55:26 UTC (rev 10169)
@@ -53,8 +53,13 @@
import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
+import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSException;
+import org.w3c.dom.ls.LSParser;
import org.w3c.dom.svg.SVGDocument;
import java.io.BufferedInputStream;
@@ -63,6 +68,7 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -315,7 +321,50 @@
getLogger().error("could not write svg file :" + e.getMessage());
getLogger().error(e.getMessage());
}
+ }
+ /**
+ * Converts a URL to a generic DOM Document.
+ * @param url The URL to be parsed to a DOM document.
+ * @return The DOM document.
+ * @throws IOException For errors parsing the document.
+ */
+ public Document urlToDom(final URL url) throws IOException {
+ DOMImplementationRegistry registry = null;
+ try {
+ registry = DOMImplementationRegistry.newInstance();
+ } catch (final ClassCastException e) {
+ throw new IOException(e.getMessage());
+ } catch (final ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ } catch (final InstantiationException e) {
+ throw new IOException(e.getMessage());
+ } catch (final IllegalAccessException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ final DOMImplementationLS impl =
+ (DOMImplementationLS) registry.getDOMImplementation("LS");
+
+ final LSParser builder = impl.createLSParser(
+ DOMImplementationLS.MODE_SYNCHRONOUS, null);
+
+ String uriString = null;
+ try {
+ uriString = url.toURI().toString();
+ } catch (final URISyntaxException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ Document document = null;
+ try {
+ document = builder.parseURI(uriString);
+ } catch (final DOMException e) {
+ throw new IOException(e.getMessage());
+ } catch (final LSException e) {
+ throw new IOException(e.getMessage());
+ }
+ return document;
}
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2007-08-10 22:54:29 UTC (rev 10168)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2007-08-10 22:55:26 UTC (rev 10169)
@@ -28,8 +28,8 @@
package org.foray.graphic.factory;
+import net.sourceforge.jeuclid.DOMBuilder;
import net.sourceforge.jeuclid.MathBase;
-import net.sourceforge.jeuclid.MathMLParserSupport;
import org.foray.graphic.FOrayGraphicServer;
import org.foray.graphic.SVGGraphic;
@@ -42,12 +42,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
-import org.xml.sax.SAXException;
import java.awt.Dimension;
import java.io.BufferedInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
/**
@@ -84,16 +82,9 @@
}
/* Convert to an SVG and create an SVGGraphic instance. */
- MathBase mathBase = null;
- try {
- final InputStream inputStream = url.openStream();
- final Document xmlDocument =
- MathMLParserSupport.parseInputStreamXML(inputStream);
- mathBase = MathMLParserSupport.createMathBaseFromDocument(
- xmlDocument, MathBase.getDefaultParameters());
- } catch (final SAXException e) {
- throw new IOException(e.getMessage());
- }
+ final Document dom = this.getServer().urlToDom(url);
+ final MathBase mathBase = new MathBase(MathBase.getDefaultParameters());
+ new DOMBuilder(dom, mathBase);
SVGDocument svgDocument = null;
try {
Modified: trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml
===================================================================
--- trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml 2007-08-10 22:54:29 UTC (rev 10168)
+++ trunk/foray/resource/fo-examples/graphics/mathml-example-1.xml 2007-08-10 22:55:26 UTC (rev 10169)
@@ -3,7 +3,7 @@
PUBLIC "-//W3C//DTD MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">
-<math mode="display">
+<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<munderover>
<mo>∫</mo>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-08-10 23:02:02
|
Revision: 10170
http://foray.svn.sourceforge.net/foray/?rev=10170&view=rev
Author: victormote
Date: 2007-08-10 16:01:54 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
Change the name of two implementation classes to make their names conform to our naming standards.
Modified Paths:
--------------
trunk/foray/doc/web/module/graphic/index.html
trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/PDFGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/PNGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/BMPFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/EPSFactory.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/JPEGFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PNGFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/SVGFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/TIFFFactory.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestAbstractGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestBmpGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGifGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestJpegGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestPngGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestSvgGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestTiffGraphic.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicServer4a.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
Modified: trunk/foray/doc/web/module/graphic/index.html
===================================================================
--- trunk/foray/doc/web/module/graphic/index.html 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/doc/web/module/graphic/index.html 2007-08-10 23:01:54 UTC (rev 10170)
@@ -40,8 +40,8 @@
<p>The FOray-specific tasks that are needed to bootstrap the use of FOrayGraphic
are as follows:</p>
<ol>
- <li>Obtain a FOrayGraphicServer instance.
-FOrayGraphicServer is an aXSL GraphicServer implementation, and can be
+ <li>Obtain a GraphicServer4a instance.
+GraphicServer4a is an aXSL GraphicServer implementation, and can be
instantiated using its constructor.
It is safe to create multiple instances, but this should be necessary only in
extremely sophisticated environments.
@@ -59,7 +59,7 @@
<p>Here is some sample bootstrap code:</p>
<pre>// Instantiate the server
Log logger = org.foray.common.Logging.makeDefaultLogger();
-GraphicServer server = new FOrayGraphicServer(logger);</pre>
+GraphicServer server = new GraphicServer4a(logger);</pre>
<h2><a name="limitations">Known Limitations</a></h2>
<ul>
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2007-08-10 23:01:54 UTC (rev 10170)
@@ -36,7 +36,7 @@
import org.foray.core.SessionConfig;
import org.foray.font.FOrayFontServer;
import org.foray.fotree.FOrayFOTreeServer;
-import org.foray.graphic.FOrayGraphicServer;
+import org.foray.graphic.GraphicServer4a;
import org.foray.pioneer.PioneerFactory;
import org.foray.speech.SpeechServer4a;
@@ -183,7 +183,7 @@
*/
public static GraphicServer makeGraphicServer(final Log logger)
throws FOrayException {
- return new FOrayGraphicServer(logger);
+ return new GraphicServer4a(logger);
}
/**
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java 2007-08-10 23:01:54 UTC (rev 10170)
@@ -46,7 +46,7 @@
/**
* A BMP (bitmap) image.
*/
-public class BMPGraphic extends FOrayGraphic {
+public class BMPGraphic extends Graphic4a {
/** The length, in bytes, of the headermap. */
private static final int HEADERMAP_LENGTH = 54;
@@ -83,7 +83,7 @@
* @param bis The reusable input stream containing the bytes from
* <code>url</code>.
*/
- public BMPGraphic(final FOrayGraphicServer server, final URL url,
+ public BMPGraphic(final GraphicServer4a server, final URL url,
final BufferedInputStream bis) {
super(server, url, bis);
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java 2007-08-10 23:01:54 UTC (rev 10170)
@@ -43,7 +43,7 @@
/**
* An EPS (encapsulated Postscript) graphic.
*/
-public class EPSGraphic extends FOrayGraphic
+public class EPSGraphic extends Graphic4a
implements org.axsl.graphic.EpsGraphic {
/** The size, in bytes, of the read buffer to use when reading the file. */
@@ -119,7 +119,7 @@
* @param isASCII Indicates whether this file format is ASCII (true) or
* binary (false).
*/
- public EPSGraphic(final FOrayGraphicServer server, final URL url,
+ public EPSGraphic(final GraphicServer4a server, final URL url,
final BufferedInputStream bis, final boolean isASCII) {
super(server, url, bis);
this.docName = url.toString();
Deleted: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-08-10 23:01:54 UTC (rev 10170)
@@ -1,592 +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.graphic;
-
-import org.foray.common.WKConstants;
-import org.foray.graphic.factory.GraphicFactory;
-
-import org.axsl.graphic.GraphicException;
-
-import org.apache.commons.logging.Log;
-
-import java.awt.Color;
-import java.awt.color.ColorSpace;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * Abstract base class for graphics.
- * @author Eric Schaeffer
- * @author <a href="mailto:ebd...@mt...">Eric Dalquist</a>
- */
-public abstract class FOrayGraphic implements org.axsl.graphic.Graphic {
-
- /** The bit depth (bits per pixel) for a monochrome image. */
- public static final byte BIT_DEPTH_MONOCHROME = 1;
-
- /** The bit depth (bits per pixel) for a 4-bit image. */
- public static final byte BIT_DEPTH_4 = 4;
-
- /** The bit depth (bits per pixel) for an 8-bit image. */
- public static final byte BIT_DEPTH_GRAYSCALE = 8;
-
- /** 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.
- */
- private static final int DEFAULT_MAX_BYTES_TO_PARSE_BASICS = 1024;
-
- /** The parent server instance. */
- private FOrayGraphicServer server;
-
- /** Some image files, such as Photoshop-generated cmyk jpegs are
- * inverted. */
- private boolean inverted = false;
-
- /** Image width (in pixel). */
- private int pixelWidth = 0;
-
- /** Image height (in pixel). */
- private int pixelHeight = 0;
-
- /** Image URL. */
- private URL url = null;
-
- /** The physical file. */
- private InputStream bis = null;
-
- /** Image color space. */
- private ColorSpace colorSpace = null;
-
- /** Bits per pixel. */
- private int bitDepth = 0;
-
- /** Image data (uncompressed). */
- private byte[] content = null;
-
- /** Image transparency. */
- private boolean isTransparent = false;
-
- /** Transparent color. */
- private Color transparentColor = null;
-
- /**
- * Set to true if the basics of the file have been parsed, that is, the
- * width has been stored in {@link #pixelWidth}, and the height has been
- * stored in {@link #pixelHeight}. Setting these values is typically done in
- * {@link #parseBasics()}, but could conceivably be done during
- * construction.
- */
- private boolean basicsParsed = false;
-
- /** Indicates whether this image has already been loaded. If so, we know
- * some basic information about it. */
- private boolean imageLoaded = false;
-
- /** 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.
- * @param url The URL which contains the graphic content.
- * @param bis The reusable input stream containing the bytes from
- * <code>url</code>.
- */
- public FOrayGraphic(final FOrayGraphicServer server, final URL url,
- final BufferedInputStream bis) {
- this.server = server;
- this.url = url;
- this.bis = bis;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isInverted() {
- return this.inverted;
- }
-
- /**
- * {@inheritDoc}
- */
- public URL getUrl() {
- return this.url;
- }
-
- /**
- * {@inheritDoc}
- */
- public int pixelWidth() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelWidth;
- }
-
- /**
- * {@inheritDoc}
- */
- public int pixelHeight() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelHeight;
- }
-
- /**
- * {@inheritDoc}
- */
- public ColorSpace getColorSpace() throws GraphicException {
- this.loadImageWrapper();
- return this.colorSpace;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getBitsPerComponent() throws GraphicException {
- this.loadImageWrapper();
- return this.bitDepth;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransparent() throws GraphicException {
- this.loadImageWrapper();
- return this.isTransparent;
- }
-
- /**
- * {@inheritDoc}
- */
- public Color getTransparentColor() throws GraphicException {
- this.loadImageWrapper();
- return this.transparentColor;
- }
-
- /**
- * {@inheritDoc}
- */
- public byte[] getContent() throws GraphicException {
- this.loadImageWrapper();
- return this.content;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getContentSize() throws GraphicException {
- this.loadImageWrapper();
- if (this.content == null) {
- return 0;
- }
- return this.content.length;
- }
-
- /**
- * {@inheritDoc}
- */
- public synchronized void close() {
- /*
- * For the moment, only release the bitmaps (image areas
- * can share the same Graphic object)
- * Thus, even if it had been called, other properties
- * are still available.
- */
- this.content = null;
- }
-
- /**
- * Wrapper for the loadImage method which takes care of some housekeeping
- * chores before and after.
- * @throws GraphicException For errors during load of image.
- */
- protected synchronized void loadImageWrapper() throws GraphicException {
- if (this.imageLoaded) {
- return;
- }
- loadImage();
- this.imageLoaded = true;
- }
-
- /**
- * Load image data and initialize its properties.
- * Subclasses need to implement this method.
- * @exception GraphicException an error occured during loading
- */
- protected abstract void loadImage() throws GraphicException;
-
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Log getLogger() {
- return this.server.getLogger();
- }
-
- /**
- * <p>This method handles some of the common housekeeping work for
- * {@link #parseBasics()} so that it can focus on parsing. Specifically,
- * this method is responsible to:</p>
- *
- * <ul>
- * <li>(Before} Check the {@link #basicsParsed} flag, and exit the parsing
- * if it has already been done.
- * <li>(Before) Reset the BufferedInputStream {@link #bis} to byte 0, and
- * mark it so that it can be reset after parsing. For this to work
- * correctly, the related GraphicFactory instance must return the correct
- * value at {@link GraphicFactory#maxBytesToVerify()}.</li>
- * <li>(During) Handles the process of catching IOExceptions and
- * converting them to GraphicExceptions.</li>
- * <li>(After) Reset the BufferedInputStream {@link #bis} to byte 0 in
- * preparation for future use. For this to work correctly, this instance
- * must return the correct value at {@link #maxBytesToParseBasics()}.</li>
- * <li>(After) Notify subsequent interested parties that the parsing has
- * been completed by setting {@link #basicsParsed} to true.</li>
- * </ul>
- * @throws GraphicException For any unrecoverable problems during parsing.
- */
- private synchronized void parseBasicsWrapper() throws GraphicException {
- if (this.basicsParsed) {
- return;
- }
- try {
- this.bis.reset();
- this.bis.mark(this.maxBytesToParseBasics());
- parseBasics();
- this.bis.reset();
- } catch (final IOException e) {
- throw new GraphicException(e.getMessage());
- }
- this.basicsParsed = true;
- }
-
- /**
- * <p>This abstract method is implemented in subclasses to initiate parsing
- * of enough of the image for it to be used in layout. This method is
- * responsible to:</p>
- * <ol>
- * <li>store the image's intrinsic width in {@link #pixelWidth}</li>
- * <li>store the image's intrinsic height in {@link #pixelHeight}</li>
- * </ol>
- *
- * <p>The housekeeping work related to resetting the buffer, handling
- * IOExceptions, and managing whether this method should be run are
- * handled elsewhere.
- * In short, this method does not need to address the details handled
- * there.</p>
- * @throws IOException For IO errors during reading of the file.
- */
- protected abstract void parseBasics() throws IOException;
-
- /**
- * Tells {@link #parseBasicsWrapper()} how large to set the
- * <code>readlimit</code> value when marking the beginning of the stream,
- * so that is can be reused.
- * The default value is 1024. Subclasses that need to read more than this
- * amount when parsing the basics from the stream should override this
- * method and return a higher amount. Otherwise, subsequent attempts to
- * use the stream will result in i/o errors.
- * @return The maximum number of bytes that might need to be read from
- * the stream to be able to parse the basics.
- */
- protected int maxBytesToParseBasics() {
- return FOrayGraphic.DEFAULT_MAX_BYTES_TO_PARSE_BASICS;
- }
-
- /**
- * {@inheritDoc}
- */
- public final int absoluteWidth(final int pixelsPerInch)
- throws GraphicException {
- final int absoluteWidth = absoluteWidthReal();
- if (absoluteWidth > 0) {
- // The graphic knows its absolute width.
- return absoluteWidth;
- }
- if (pixelsPerInch < 1) {
- // The user does not want the fallback computation.
- return -1;
- }
- final int pixelWidth = pixelWidth();
- if (pixelWidth < 1) {
- // pixel Width is not valid
- return -1;
- }
- final int computedWidth = Math.round(
- ((float) pixelWidth / (float) pixelsPerInch)
- * WKConstants.POINTS_PER_INCH
- * WKConstants.MILLIPOINTS_PER_POINT);
- return computedWidth;
- }
-
- /**
- * Subclasses that know how to compute the absolute width of the image
- * should override this method.
- * @return The absolute width, in millipoints, of this graphic, if known.
- * If not known, returns -1.
- * @throws GraphicException For errors during reading of image file.
- */
- public int absoluteWidthReal() throws GraphicException {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- public final int absoluteHeight(final int pixelsPerInch)
- throws GraphicException {
- final int absoluteHeight = absoluteHeightReal();
- if (absoluteHeight > 0) {
- // The graphic knows its absolute height.
- return absoluteHeight;
- }
- if (pixelsPerInch < 1) {
- // The user does not want the fallback computation.
- return -1;
- }
- final int pixelHeight = pixelHeight();
- if (pixelHeight < 1) {
- // pixel Height is not valid
- return -1;
- }
- final int computedHeight = Math.round(
- ((float) pixelHeight / (float) pixelsPerInch)
- * WKConstants.POINTS_PER_INCH
- * WKConstants.MILLIPOINTS_PER_POINT);
- return computedHeight;
- }
-
- /**
- * Subclasses that know how to compute the absolute width of the image
- * should override this method.
- * @return The absolute height, in millipoints, of this graphic, if known.
- * If not known, returns -1.
- * @throws GraphicException For errors during reading of image file.
- */
- public int absoluteHeightReal() throws GraphicException {
- return -1;
- }
-
- /**
- * Return the server.
- * @return Returns the server.
- */
- public FOrayGraphicServer getServer() {
- return this.server;
- }
-
- /**
- * Indicates whether this graphic is valid.
- * @return Returns true iff this graphic is valid.
- */
- public boolean isValid() {
- return this.isValid;
- }
-
- /**
- * Sets the validity of this graphic.
- * @param isValid The new validity value.
- */
- public void setValid(final boolean isValid) {
- this.isValid = isValid;
- }
-
- /**
- * Indicates whether the image has been loaded.
- * @return Returns true iff the image has been loaded.
- */
- public boolean isImageLoaded() {
- return this.imageLoaded;
- }
-
- /**
- * Sets the "image loaded" value.
- * @param imageLoaded The new "image loaded" value.
- */
- public void setImageLoaded(final boolean imageLoaded) {
- this.imageLoaded = imageLoaded;
- }
-
- /**
- * Sets the transparent color.
- * @param transparentColor The new transparent Color.
- */
- public void setTransparentColor(final Color transparentColor) {
- this.transparentColor = transparentColor;
- }
-
- /**
- * Sets the tranparency value.
- * @param isTransparent The new transparency value.
- */
- public void setTransparent(final boolean isTransparent) {
- this.isTransparent = isTransparent;
- }
-
- /**
- * Sets the content for this graphic.
- * @param content The new content.
- */
- public void setContent(final byte[] content) {
- this.content = content;
- }
-
- /**
- * Sets the bit depth for this graphic.
- * @param bitDepth The new bit depth.
- */
- public void setBitDepth(final int bitDepth) {
- this.bitDepth = bitDepth;
- }
-
- /**
- * Returns the bit depth for this graphic.
- * @return The bit depth for this graphic.
- */
- public int getBitDepth() {
- return this.bitDepth;
- }
-
- /**
- * Sets the color space for this graphic.
- * @param colorSpace The new color space.
- */
- public void setColorSpace(final ColorSpace colorSpace) {
- this.colorSpace = colorSpace;
- }
-
- /**
- * Returns the color space without throwing any exceptions.
- * @return The color space.
- * @see #getColorSpace()
- */
- public ColorSpace getRawColorSpace() {
- return this.colorSpace;
- }
-
- /**
- * Returns the input stream for this file.
- * @return Returns the input stream.
- */
- public InputStream getInputStream() {
- return this.bis;
- }
-
- /**
- * Sets the input stream for this file.
- * @param inputStream The new input stream.
- */
- public void setInputStream(final InputStream inputStream) {
- this.bis = inputStream;
- }
-
- /**
- * Sets the height in pixels of this graphic.
- * @param pixelHeight The new height in pixels.
- */
- public void setPixelHeight(final int pixelHeight) {
- this.pixelHeight = pixelHeight;
- }
-
- /**
- * Returns the height in pixesls of this graphic, without throwing any
- * exceptions.
- * @return The height in pixels of this graphic.
- * @see #pixelHeight()
- */
- public int getRawPixelHeight() {
- return this.pixelHeight;
- }
-
- /**
- * Sets the width in pixels of this graphic.
- * @param pixelWidth The new width in pixels.
- */
- public void setPixelWidth(final int pixelWidth) {
- this.pixelWidth = pixelWidth;
- }
-
- /**
- * Returns the width in pixesls of this graphic, without throwing any
- * exceptions.
- * @return The width in pixels of this graphic.
- * @see #pixelWidth()
- */
- public int getRawPixelWidth() {
- return this.pixelWidth;
- }
-
- /**
- * Sets the flag indicating whether this graphic is inverted.
- * @param inverted Set to true to indicate that the image is inverted.
- */
- public void setInverted(final boolean inverted) {
- 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;
- }
-
- /**
- * Returns the links associated with this graphic.
- * @return The links associated with this graphic.
- */
- public GraphicLink4a[] getLinks() {
- if (this.links == null) {
- return FOrayGraphic.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;
- }
-
-}
Deleted: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-10 22:55:26 UTC (rev 10169)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-08-10 23:01:54 UTC (rev 10170)
@@ -1,370 +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.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;
-import org.foray.graphic.factory.EPSFactory;
-import org.foray.graphic.factory.GIFFactory;
-import org.foray.graphic.factory.GraphicFactory;
-import org.foray.graphic.factory.JPEGFactory;
-import org.foray.graphic.factory.MathFactory;
-import org.foray.graphic.factory.PDFFactory;
-import org.foray.graphic.factory.PNGFactory;
-import org.foray.graphic.factory.SVGFactory;
-import org.foray.graphic.factory.TIFFFactory;
-
-import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.GraphicServer;
-
-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.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSException;
-import org.w3c.dom.ls.LSParser;
-import org.w3c.dom.svg.SVGDocument;
-
-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.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * create Graphic objects (with a configuration file - not yet implemented).
- * @author Eric SCHAEFFER
- */
-public class FOrayGraphicServer implements GraphicServer {
-
- /** The logger that should be used by this server. */
- private Log logger;
-
- /**
- * The name of the class that should be used to parse SVG documents.
- * This is needed by Batik.
- */
- private String svgParserClassName;
-
- /** Collection of standard GraphicFactory instances that can be used. */
- private List<GraphicFactory> standardFactories
- = new ArrayList<GraphicFactory>();
-
- /** Collection of custom GraphicFactory instances that can be used. */
- private List<GraphicFactory> customFactories
- = new ArrayList<GraphicFactory>();
-
- /**
- * If graphic caching is enabled, this collection caches graphic objects for
- * reuse. A String containing the image location as the key, and the
- * Graphic instance is the value.
- */
- private Map<String, FOrayGraphic> urlMap
- = new HashMap<String, FOrayGraphic>();
-
- /**
- * Constructor.
- * @param logger The logger.
- */
- public FOrayGraphicServer(final Log logger) {
- this.logger = logger;
- if (this.logger == null) {
- this.logger = Logging.makeDefaultLogger();
- }
- this.svgParserClassName = SaxParser.getParserClassName();
- registerStandardFactories();
- }
-
- /**
- * Registers the predefined standard factories.
- */
- private void registerStandardFactories() {
- this.standardFactories.add(new BMPFactory(this));
- this.standardFactories.add(new EPSFactory(this));
- this.standardFactories.add(new GIFFactory(this));
- this.standardFactories.add(new JPEGFactory(this));
- this.standardFactories.add(new SVGFactory(this));
- this.standardFactories.add...
[truncated message content] |
|
From: <vic...@us...> - 2007-08-10 23:56:58
|
Revision: 10171
http://foray.svn.sourceforge.net/foray/?rev=10171&view=rev
Author: victormote
Date: 2007-08-10 16:56:56 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
1. Add a test of the DOM parsing capability.
2. Refactor the logic for getting the sandbox and test directory so that it can be reused.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java 2007-08-10 23:01:54 UTC (rev 10170)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java 2007-08-10 23:56:56 UTC (rev 10171)
@@ -29,8 +29,8 @@
package org.foray.app.fo;
import org.foray.app.FOraySpecific;
-import org.foray.common.Environment;
import org.foray.common.Logging;
+import org.foray.common.TestFOrayCommon;
import org.foray.common.sax.SaxParser;
import org.foray.common.url.URLFactory;
import org.foray.core.FOrayException;
@@ -56,7 +56,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.Properties;
import javax.xml.parsers.ParserConfigurationException;
@@ -85,11 +84,7 @@
final Log logger = Logging.makeQuietLogger();
final SessionConfig sessionConfig = new SessionConfig(logger);
- final Properties buildProperties = Environment.getBuildProperties();
- final String foraySandbox = buildProperties.getProperty(
- "foray.sandbox");
- final String testDir = foraySandbox + "/resource/test/";
- this.testDirectory = new File(testDir);
+ this.testDirectory = TestFOrayCommon.getTestDirectory();
final FontServer fontServer = FOraySpecific.makeFontServer(logger,
sessionConfig);
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2007-08-10 23:01:54 UTC (rev 10170)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2007-08-10 23:56:56 UTC (rev 10171)
@@ -28,6 +28,10 @@
package org.foray.common;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -38,6 +42,29 @@
public class TestFOrayCommon extends TestCase {
/**
+ * Returns the directory that is the root of the local sandbox, for example,
+ * "D:/u/user/foray/trunk/foray".
+ * @return The directory that is the root of the local sandbox.
+ * @throws IOException For errors obtaining the build properties.
+ */
+ public static File getSandbox() throws IOException {
+ final Properties buildProperties = Environment.getBuildProperties();
+ final String foraySandbox = buildProperties.getProperty(
+ "foray.sandbox");
+ return new File(foraySandbox);
+ }
+
+ /**
+ * Returns the local file that contains the test files.
+ * @return The local file that contains the test files.
+ * @throws IOException For errors obtaining the build properties.
+ */
+ public static File getTestDirectory() throws IOException {
+ final File sandbox = TestFOrayCommon.getSandbox();
+ return new File(sandbox, "/resource/test/");
+ }
+
+ /**
* Builds a test suite for all classes in this module.
* @return The built test suite.
*/
Modified: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java 2007-08-10 23:01:54 UTC (rev 10170)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java 2007-08-10 23:56:56 UTC (rev 10171)
@@ -44,6 +44,7 @@
public static Test suite() {
final TestSuite testSuite = new TestSuite();
+ testSuite.addTestSuite(TestGraphicServer4a.class);
testSuite.addTestSuite(TestBmpGraphic.class);
testSuite.addTestSuite(TestGifGraphic.class);
testSuite.addTestSuite(TestJpegGraphic.class);
Added: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java 2007-08-10 23:56:56 UTC (rev 10171)
@@ -0,0 +1,137 @@
+/*
+ * 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.foray.common.Logging;
+import org.foray.common.TestFOrayCommon;
+
+import org.axsl.graphic.GraphicException;
+
+import org.apache.commons.logging.Log;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the class {@link GraphicServer4a}.
+ */
+public class TestGraphicServer4a extends TestCase {
+
+ /** A GraphicServer available for testing. */
+ private static GraphicServer4a graphicServer;
+
+ /**
+ * Provides static access to a static GraphicServer4a instance for testing.
+ * @return The GraphicServer4a to be used for testing.
+ * @throws GraphicException For errors creating the Server.
+ */
+ public static GraphicServer4a getServer() throws GraphicException {
+ if (TestGraphicServer4a.graphicServer == null) {
+ final Log logger = Logging.makeDefaultLogger();
+ final GraphicServer4a graphicServer = new GraphicServer4a(logger);
+ TestGraphicServer4a.graphicServer = graphicServer;
+ }
+ return TestGraphicServer4a.graphicServer;
+ }
+
+ /**
+ * Returns the directory containing the graphics files used for testing.
+ * @return The directory containing the graphics files used for testing.
+ * @throws IOException For errors obtaining the local sandbox.
+ */
+ public static File getTestGraphicsDir() throws IOException {
+ final File sandbox = TestFOrayCommon.getSandbox();
+ final File graphicsDir = new File(sandbox,
+ "resource/fo-examples/graphics");
+ return graphicsDir;
+ }
+
+ /**
+ * Returns the file for a given test graphic file.
+ * @param fileName The name of the test graphic file to obtain.
+ * @return The file.
+ * @throws IOException For errors obtaining the local sandbox or for the
+ * file itself.
+ */
+ public static File getTestGraphicsFile(final String fileName)
+ throws IOException {
+ final File graphicsDir = TestGraphicServer4a.getTestGraphicsDir();
+ return new File(graphicsDir, fileName);
+ }
+
+ /**
+ * Test the method {@link GraphicServer4a#urlToDom(java.net.URL)} by parsing
+ * a file and testing the results.
+ * @throws IOException For errors getting the local sandbox.
+ * @throws GraphicException For error obtaining a server instance.
+ */
+ public void testUrlToDom() throws IOException, GraphicException {
+ final File testFile = TestGraphicServer4a.getTestGraphicsFile(
+ "mathml-example-1.xml");
+ final URL url = testFile.toURL();
+ final GraphicServer4a server = TestGraphicServer4a.getServer();
+ final Document document = server.urlToDom(url);
+ assertNotNull(document);
+
+ /* The document itself has two children, the document type, and the
+ * root element. */
+ NodeList nodeList = document.getChildNodes();
+ assertEquals(2, nodeList.getLength());
+ /* The first node is the document type node. */
+ assertEquals(Node.DOCUMENT_TYPE_NODE, nodeList.item(0).getNodeType());
+
+ /* The second node is the root element. */
+ Node node = nodeList.item(1);
+ assertEquals(Node.ELEMENT_NODE, node.getNodeType());
+ assertEquals("math", node.getLocalName());
+
+ /* The root node has one child, an "mrow" element. */
+ nodeList = node.getChildNodes();
+ assertEquals(3, nodeList.getLength());
+ /* The first child is ignorable whitespace. */
+ assertEquals(Node.TEXT_NODE, nodeList.item(0).getNodeType());
+ /* The second child is the actual element. */
+ assertEquals(Node.ELEMENT_NODE, nodeList.item(1).getNodeType());
+ /* The third child is ignorable whitespace. */
+ assertEquals(Node.TEXT_NODE, nodeList.item(2).getNodeType());
+ node = nodeList.item(1);
+ assertEquals("mrow", node.getLocalName());
+
+ /* It is certainly possible to test this DOM document more extensively,
+ * but this is enough to show that it was parsed. */
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java
___________________________________________________________________
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-08-11 20:16:45
|
Revision: 10174
http://foray.svn.sourceforge.net/foray/?rev=10174&view=rev
Author: victormote
Date: 2007-08-11 13:16:45 -0700 (Sat, 11 Aug 2007)
Log Message:
-----------
Rough-in support for the MathML namespace for instream-foreign-object.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java
trunk/foray/resource/fo-examples/basic/instream.fo
Added Paths:
-----------
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathNamespace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathObjectMaker.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/InstreamMathElement.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2007-08-11 16:14:11 UTC (rev 10173)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -34,6 +34,7 @@
import org.foray.fotree.fo.obj.PageSequence;
import org.foray.fotree.fo.obj.Root;
import org.foray.fotree.foray.NamespaceForay;
+import org.foray.fotree.math.MathNamespace;
import org.foray.fotree.svg.NamespaceSVG;
import org.foray.fotree.xml.NamespaceXML;
@@ -436,6 +437,14 @@
}
/**
+ * Return the MathML namespace instance.
+ * @return The MathML namespace instance.
+ */
+ public MathNamespace getMathNamespace() {
+ return getTreeServer().getMathNamespace();
+ }
+
+ /**
* Return the XML namespace instance.
* @return The XML namespace instance.
*/
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java 2007-08-11 16:14:11 UTC (rev 10173)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -32,6 +32,7 @@
import org.foray.fotree.axsl.NamespaceAxsl;
import org.foray.fotree.fo.NamespaceFO;
import org.foray.fotree.foray.NamespaceForay;
+import org.foray.fotree.math.MathNamespace;
import org.foray.fotree.svg.NamespaceSVG;
import org.foray.fotree.xml.NamespaceXML;
@@ -89,6 +90,9 @@
/** The "SVG" namespace. */
private NamespaceSVG namespaceSVG;
+ /** The "MathML" namespace. */
+ private MathNamespace namespaceMath;
+
/** The "XML namespace. */
private NamespaceXML namespaceXML;
@@ -133,6 +137,9 @@
final NamespaceSVG svg = new NamespaceSVG();
registerNamespace(svg);
this.namespaceSVG = svg;
+ final MathNamespace math = new MathNamespace();
+ this.registerNamespace(math);
+ this.namespaceMath = math;
final NamespaceForay extensions = new NamespaceForay();
registerNamespace(extensions);
this.namespaceForay = extensions;
@@ -198,6 +205,14 @@
}
/**
+ * Returns the namespace used for "MathML" items.
+ * @return The namespace used for "MathML" items.
+ */
+ public MathNamespace getMathNamespace() {
+ return this.namespaceMath;
+ }
+
+ /**
* Returns the namespace used for "XML" items.
* @return The namespace used for "XML" items.
*/
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java 2007-08-11 16:14:11 UTC (rev 10173)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -165,8 +165,8 @@
/**
* This is pretending to be a SAX Handler for the start of an element.
- * Control is passed here from FOTreeBuilder while foreign XML is being
- * processed.
+ * Control is passed here from {@link FOTreeBuilder#startElement(String,
+ * String, String, Attributes)} while foreign XML is being processed.
* @param namespaceURI The Namespace URI, or the empty string if the element
* has no Namespace URI or if Namespace processing is not being performed.
* @param localName The local name (without prefix), or the empty string if
@@ -212,8 +212,8 @@
/**
* This is pretending to be a SAX Handler for the end of an element.
- * Control is passed here from FOTreeBuilder while foreign XML is being
- * processed.
+ * Control is passed here from {@link FOTreeBuilder#endElement(String,
+ * String, String)} while foreign XML is being processed.
* @param uri The Namespace URI, or the empty string if the element has no
* Namespace URI or if Namespace processing is not being performed.
* @param localName The local name (without prefix), or the empty string if
@@ -248,8 +248,8 @@
/**
* This is pretending to be a SAX Handler for the characters (content) of
* an element.
- * Control is passed here from FOTreeBuilder while foreign XML is being
- * processed.
+ * Control is passed here from {@link FOTreeBuilder#characters(char[], int,
+ * int)} while foreign XML is being processed.
* @param data The characters.
* @param start The start position in the character array.
* @param length The number of characters to use from the character array.
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathNamespace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathNamespace.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathNamespace.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -0,0 +1,112 @@
+/*
+ * 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: victormote $
+ */
+
+package org.foray.fotree.math;
+
+import org.foray.fotree.FOTreeBuilder;
+import org.foray.fotree.FObj;
+import org.foray.fotree.Namespace;
+import org.foray.fotree.Property;
+import org.foray.fotree.PropertyException;
+import org.foray.fotree.PropertyList;
+import org.foray.fotree.PropertyListUnparsed;
+
+import org.axsl.fo.FoTreeException;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
+/**
+ * This class manages the namespace that is used for the Math Markup Language
+ * (MathML).
+ */
+public class MathNamespace extends Namespace {
+
+ /**
+ * Constructor.
+ */
+ public MathNamespace() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNamespaceURI() {
+ return "http://www.w3.org/1998/Math/MathML";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTypicalPrefix() {
+ return "m";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public FObj parseElementForNS(final String localName,
+ final FObj currentFObj, final PropertyList list,
+ final Locator locator) throws FoTreeException {
+ return MathObjectMaker.makeObject(localName, currentFObj, list);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void parseAttributes(final PropertyList propertyList,
+ final Attributes attlist, final FObj currentFObj,
+ final Locator locator, final FOTreeBuilder builder) {
+ /*
+ * There is nothing to do here. We passed the raw attributes when
+ * we created the propertyList instance.
+ */
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Property parseAttributeForNS(final Attributes attributes,
+ final String attributeName, final String attributeValue,
+ final FObj fobj, final Locator locator)
+ throws PropertyException {
+ /* This method is required by the abstract superclass Namespace, but is
+ * not used, because the parseAttributes method does all of the work. */
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected PropertyList createNewPropertyList(final Attributes attlist) {
+ return new PropertyListUnparsed(attlist);
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathNamespace.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathObjectMaker.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathObjectMaker.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathObjectMaker.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -0,0 +1,82 @@
+/*
+ * 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.fotree.math;
+
+import org.foray.fotree.FObj;
+import org.foray.fotree.PropertyList;
+import org.foray.fotree.PropertyListUnparsed;
+import org.foray.fotree.fo.obj.InstreamForeignObject;
+import org.foray.fotree.svg.obj.SVGElement;
+
+import org.axsl.fo.FoTreeException;
+
+/**
+ * Factory class for creating formatting objects in the "m" (MathML) namespace.
+ */
+public final class MathObjectMaker {
+
+ /**
+ * Private constructor. This is a utility class and should never be
+ * instantiated.
+ */
+ private MathObjectMaker() { }
+
+ /**
+ * Converts an unparsed SVG element into an FObj instance that can be added
+ * to the FO Tree.
+ * @param objectName The unparsed SVG element name.
+ * @param parent The parent FObj.
+ * @param propertyList The property list of the parent FObj.
+ * @return The new FObj instance for this SVG element.
+ * @throws FoTreeException If the parent object is not an instance of
+ * {@link InstreamForeignObject}.
+ */
+ public static FObj makeObject(final String objectName, final FObj parent,
+ final PropertyList propertyList) throws FoTreeException {
+ /* We only need to handle one element here, the root element, which is
+ * always "math". */
+ if (! objectName.equals("math")) {
+ throw new IllegalArgumentException("Cannot parse any MathML "
+ + "elements except \"math\".");
+ }
+ // The PropertyList must be of the unparsed variety
+ final PropertyListUnparsed propertyListUnparsed
+ = (PropertyListUnparsed) propertyList;
+ if (parent instanceof InstreamForeignObject) {
+ final InstreamForeignObject ifo =
+ (InstreamForeignObject) parent;
+ return new SVGElement(ifo, propertyListUnparsed);
+ } else {
+ parent.throwException("Instream MathML content must be inside "
+ + "an fo:instream-foreign-object.");
+ return null;
+ }
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/MathObjectMaker.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/InstreamMathElement.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/InstreamMathElement.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/InstreamMathElement.java 2007-08-11 20:16:45 UTC (rev 10174)
@@ -0,0 +1,75 @@
+/*
+ * 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.fotree.math.obj;
+
+import org.foray.fotree.Namespace;
+import org.foray.fotree.PropertyListUnparsed;
+import org.foray.fotree.fo.obj.InstreamForeignObject;
+import org.foray.fotree.svg.obj.SVGElement;
+
+import org.axsl.fo.FoTreeException;
+import org.axsl.graphic.GraphicException;
+
+import org.w3c.dom.Document;
+
+/**
+ * The content of an instream Math (MathML) document.
+ */
+public class InstreamMathElement extends SVGElement {
+
+ /**
+ * Constructor.
+ * @param parent The parent FObj.
+ * @param propertyList The property list for this FObj.
+ * @throws FoTreeException For errors during construction.
+ */
+ public InstreamMathElement(final InstreamForeignObject parent,
+ final PropertyListUnparsed propertyList) throws FoTreeException {
+ super(parent, propertyList);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Document createDOMDocument() throws FoTreeException {
+ try {
+ return this.getGraphicServer().makeSvgDocument();
+ } catch (final GraphicException e) {
+ throw new FoTreeException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Namespace getNamespace() {
+ return this.getFoTree().getMathNamespace();
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/InstreamMathElement.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html 2007-08-11 20:16:45 UTC (rev 10174)
@@ -0,0 +1,6 @@
+<html>
+<title>Package org.foray.fotree.math.obj</title>
+<body>
+<p>Classes representing objects in the m: (MathML) namespace.</p>
+</body>
+</html>
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html 2007-08-11 20:16:45 UTC (rev 10174)
@@ -0,0 +1,6 @@
+<html>
+<title>Package org.foray.fotree.math</title>
+<body>
+<p>Namespace and Factory classes for objects in the m: (MathML) namespace.</p>
+</body>
+</html>
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/resource/fo-examples/basic/instream.fo
===================================================================
--- trunk/foray/resource/fo-examples/basic/instream.fo 2007-08-11 16:14:11 UTC (rev 10173)
+++ trunk/foray/resource/fo-examples/basic/instream.fo 2007-08-11 20:16:45 UTC (rev 10174)
@@ -1,32 +1,38 @@
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+<fo:root
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
- <fo:region-body margin-top="25pt" margin-bottom="25pt" margin-left="50pt" margin-right="50pt" />
+ <fo:region-body
+ margin-top="25pt"
+ margin-bottom="25pt"
+ margin-left="50pt"
+ margin-right="50pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
+
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
- <fo:block>This is used to show how foreign objects are placed in a line area.</fo:block>
- <fo:block>
- Some block text to separate instream objects.
- </fo:block>
- <fo:block>
- Some text before
-<fo:instream-foreign-object>
+
+ <fo:block>This is used to show how foreign objects are placed in a line
+area.</fo:block>
+
+ <fo:block>Some block text to separate instream objects.</fo:block>
+
+ <fo:block>Some text before<fo:instream-foreign-object>
<svg:svg width="20" height="20">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
-</svg:svg>
-</fo:instream-foreign-object>
- and some after the svg element.
- </fo:block>
- <fo:block>
- A text line below the instream object.
- </fo:block>
- <fo:block>
-<fo:instream-foreign-object>
+</svg:svg></fo:instream-foreign-object> and some after the svg
+element.</fo:block>
+
+ <fo:block>A text line below the instream object.</fo:block>
+
+ <fo:block><fo:instream-foreign-object>
<svg:svg width="250" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
@@ -34,58 +40,47 @@
</svg:g>
<svg:text x="10" y="30">SVG placed in a block</svg:text>
</svg:svg>
-</fo:instream-foreign-object>
- </fo:block>
- <fo:block>
- A text line below the block.
- </fo:block>
- <fo:block>
- A text line with an instream foreign object that is before the line break.
-<fo:instream-foreign-object>
+</fo:instream-foreign-object></fo:block>
+
+ <fo:block>A text line below the block.</fo:block>
+
+ <fo:block>A text line with an instream foreign object that is before the line
+break. <fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
-</svg:svg>
-</fo:instream-foreign-object>
-With some text on the next line. With a bit more text to go over the to the next line.
- </fo:block>
- <fo:block>
- A text line with an instream foreign object that is after the line break.
-With some text on the next line. With a bit
-<fo:instream-foreign-object>
+</svg:svg></fo:instream-foreign-object> With some text on the next line. With a
+bit more text to go over the to the next line.</fo:block>
+
+ <fo:block>A text line with an instream foreign object that is after the line
+break. With some text on the next line. With a bit <fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
-</svg:svg>
-</fo:instream-foreign-object>
-more text to go over the to the next line.
- </fo:block>
- <fo:block>
- A text line with an instream foreign object that is over the line break.
-With some text
-<fo:instream-foreign-object>
+</svg:svg></fo:instream-foreign-object> more text to go over the to the next
+line.</fo:block>
+
+ <fo:block>A text line with an instream foreign object that is over the line
+break. With some text <fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
-</svg:svg>
-</fo:instream-foreign-object>
-on the next line. With a bit more text to go over the to the next line to
-see it handles it properly.
- </fo:block>
- <fo:block>
- The next block has an instream object wider than the area.
- </fo:block>
- <fo:block>
-<fo:instream-foreign-object>
+</svg:svg></fo:instream-foreign-object> on the next line. With a bit more text
+to go over the to the next line to see it handles it properly.</fo:block>
+
+ <fo:block>The next block has an instream object wider than the
+area.</fo:block>
+
+ <fo:block><fo:instream-foreign-object>
<svg:svg width="550" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
@@ -94,11 +89,10 @@
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="549" height="49"/>
<svg:text x="10" y="30">SVG placed in a really wide block</svg:text>
</svg:svg>
-</fo:instream-foreign-object>
- </fo:block>
- <fo:block>
- This block has an instream object wider than the area after this text
-<fo:instream-foreign-object>
+</fo:instream-foreign-object></fo:block>
+
+ <fo:block>This block has an instream object wider than the area after this
+text <fo:instream-foreign-object>
<svg:svg width="550" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
@@ -107,8 +101,27 @@
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="549" height="49"/>
<svg:text x="10" y="30">SVG placed in a really wide block</svg:text>
</svg:svg>
-</fo:instream-foreign-object>
- </fo:block>
- </fo:flow>
- </fo:page-sequence>
+</fo:instream-foreign-object></fo:block>
+
+ <fo:block>The next paragraph demonstrates the use of an instream MathML
+document.</fo:block>
+
+ <fo:block>This demonstration formula comes from the JEuclid web site:
+<fo:instream-foreign-object>
+<m:math display="inline">
+ <m:mrow>
+ <m:munderover>
+ <m:mo>∫</m:mo>
+ <m:mn>1</m:mn>
+ <m:mi>x</m:mi>
+ </m:munderover>
+ <m:mfrac>
+ <m:mi>dt</m:mi>
+ <m:mi>t</m:mi>
+ </m:mfrac>
+ </m:mrow>
+</m:math></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-08-28 19:36:14
|
Revision: 10184
http://foray.svn.sourceforge.net/foray/?rev=10184&view=rev
Author: victormote
Date: 2007-08-28 12:36:14 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
Upgrade JEuclid to 3.0.1.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
Added Paths:
-----------
trunk/foray/lib/jeuclid-core-3.0.1.jar
Removed Paths:
-------------
trunk/foray/lib/jeuclid-core-2.9.8.jar
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-28 19:01:26 UTC (rev 10183)
+++ trunk/foray/foray-graphic/.classpath 2007-08-28 19:36:14 UTC (rev 10184)
@@ -27,7 +27,7 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-pdf-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-pdf-transcoder-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
- <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-2.9.8.jar" sourcepath="/FOray Lib-Build/jeuclid/jeuclid-core-2.9.8-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-svggen.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-3.0.1.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Deleted: trunk/foray/lib/jeuclid-core-2.9.8.jar
===================================================================
(Binary files differ)
Added: trunk/foray/lib/jeuclid-core-3.0.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/jeuclid-core-3.0.1.jar
___________________________________________________________________
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-08-28 20:06:10
|
Revision: 10185
http://foray.svn.sourceforge.net/foray/?rev=10185&view=rev
Author: victormote
Date: 2007-08-28 13:06:10 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
Upgrade JEuclid source code.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
Added Paths:
-----------
trunk/foray/lib-build/jeuclid/jeuclid-3.0.1-source.zip
Removed Paths:
-------------
trunk/foray/lib-build/jeuclid/jeuclid-core-2.9.8-src.zip
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-28 19:36:14 UTC (rev 10184)
+++ trunk/foray/foray-graphic/.classpath 2007-08-28 20:06:10 UTC (rev 10185)
@@ -28,6 +28,6 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-pdf-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-pdf-transcoder-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-svggen.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-3.0.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/jeuclid-core-3.0.1.jar" sourcepath="/FOray Lib-Build/jeuclid/jeuclid-3.0.1-source.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Added: trunk/foray/lib-build/jeuclid/jeuclid-3.0.1-source.zip
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/jeuclid/jeuclid-3.0.1-source.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/foray/lib-build/jeuclid/jeuclid-core-2.9.8-src.zip
===================================================================
(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-08-30 22:53:02
|
Revision: 10194
http://foray.svn.sourceforge.net/foray/?rev=10194&view=rev
Author: victormote
Date: 2007-08-30 15:53:00 -0700 (Thu, 30 Aug 2007)
Log Message:
-----------
Allow the bookmark-title to be empty, and handle that case properly in the Area Tree.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java 2007-08-30 21:37:28 UTC (rev 10193)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java 2007-08-30 22:53:00 UTC (rev 10194)
@@ -28,7 +28,10 @@
package org.foray.area;
+import org.foray.common.WKConstants;
+
import org.axsl.fo.fo.BookmarkTitle;
+import org.axsl.fo.fo.CharacterSequence;
import org.axsl.font.Font;
import java.awt.Color;
@@ -72,7 +75,12 @@
*/
public String getTitleText() {
final BookmarkTitle generatedBy = traitGeneratedBy();
- final char[] text = generatedBy.getChildAt(0).getAreaTreeText(null);
+ /* Allow for the possibility that the content is empty. */
+ if (generatedBy.getChildCount() < 1) {
+ return WKConstants.EMPTY_STRING;
+ }
+ final CharacterSequence charSequence = generatedBy.getChildAt(0);
+ final char[] text = charSequence.getAreaTreeText(null);
return new String(text);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2007-08-30 21:37:28 UTC (rev 10193)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2007-08-30 22:53:00 UTC (rev 10194)
@@ -93,7 +93,7 @@
protected void validateDescendants() throws FoTreeException {
/* Validate children. Content Model: (#PCDATA)
* Must have exactly one child, an FOText instance. */
- if (this.getChildren().size() != 1) {
+ if (this.getChildren().size() > 1) {
throwException(this.getFullName() + " must have exactly one "
+ "child.");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-08-31 17:40:41
|
Revision: 10195
http://foray.svn.sourceforge.net/foray/?rev=10195&view=rev
Author: victormote
Date: 2007-08-31 10:38:51 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
Upgrade xml-graphics commons from 1.1. to 1.2.
Modified Paths:
--------------
trunk/foray/doc/web/app/using/release.html
trunk/foray/foray-graphic/.classpath
Added Paths:
-----------
trunk/foray/lib/xmlgraphics-commons-1.2.jar
trunk/foray/lib-build/xmlgraphics-commons/xmlgraphics-commons-1.2-src.zip
Removed Paths:
-------------
trunk/foray/lib/xmlgraphics-commons-1.1.jar
trunk/foray/lib-build/xmlgraphics-commons/xmlgraphics-commons-1.1-src.zip
Modified: trunk/foray/doc/web/app/using/release.html
===================================================================
--- trunk/foray/doc/web/app/using/release.html 2007-08-30 22:53:00 UTC (rev 10194)
+++ trunk/foray/doc/web/app/using/release.html 2007-08-31 17:38:51 UTC (rev 10195)
@@ -97,6 +97,8 @@
aXSL Graphic interfaces. This makes it much more feasible for users to drop in
another (perhaps commercial) SVG package. It also makes maintenance of the
Batik integration much more straightforward.</li>
+ <li>The Apache XML Graphics Commons dependency has been upgraded to
+ version 1.2.</li>
</ul>
<h2><a name="0_2">Release 0.2</a></h2>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-08-30 22:53:00 UTC (rev 10194)
+++ trunk/foray/foray-graphic/.classpath 2007-08-31 17:38:51 UTC (rev 10195)
@@ -7,7 +7,6 @@
<classpathentry kind="src" path="/axslGraphic"/>
<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/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" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
@@ -29,5 +28,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-svggen.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/jeuclid-core-3.0.1.jar" sourcepath="/FOray Lib-Build/jeuclid/jeuclid-3.0.1-source.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/xmlgraphics-commons-1.2.jar" sourcepath="/FOray Lib-Build/xmlgraphics-commons/xmlgraphics-commons-1.2-src.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Deleted: trunk/foray/lib/xmlgraphics-commons-1.1.jar
===================================================================
(Binary files differ)
Added: trunk/foray/lib/xmlgraphics-commons-1.2.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/xmlgraphics-commons-1.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/foray/lib-build/xmlgraphics-commons/xmlgraphics-commons-1.1-src.zip
===================================================================
(Binary files differ)
Added: trunk/foray/lib-build/xmlgraphics-commons/xmlgraphics-commons-1.2-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/xmlgraphics-commons/xmlgraphics-commons-1.2-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-09-10 18:01:29
|
Revision: 10202
http://foray.svn.sourceforge.net/foray/?rev=10202&view=rev
Author: victormote
Date: 2007-09-10 11:01:28 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
1. Add patgen code converted from Pascal to C by Amadeus Foudray to the repository for short-term reference.
2. Add constants and variables to the java code for the PatternGenerator.
3. Suppress checkstyle warnings in PatternGenerator for now.
Modified Paths:
--------------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
trunk/foray/scripts/checkstyle-suppressions.xml
Added Paths:
-----------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/patgen.c
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2007-09-06 22:56:55 UTC (rev 10201)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2007-09-10 18:01:28 UTC (rev 10202)
@@ -53,6 +53,9 @@
package org.foray.hyphen;
+import org.foray.common.WKConstants;
+
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -96,7 +99,149 @@
* state machine. For further details, see the \TeX 82 source.</p>
*/
public class PatternGenerator {
+ /* TODO: Turn off checkstyle suppression for this class. */
+ /* Start of Constants from TeX code. */
+ /* TODO: After conversion is complete, make all of these constants and
+ * variables private. */
+
+ /** Maximum number of levels + 1. Also used to denote bad patterns. */
+ static final byte MAX_VAL = 10;
+
+ /** A magic number for the size of the array holding the filename. */
+ private static final int FILENAME_SIZE = 9;
+
+ /** A magic number of unknown significance. */
+ private static final int HYPH_SIZE = 4;
+
+ /** A magic number of unknown significance. */
+ private static final int DIGITS_SIZE = 10;
+
+ /** Space for pattern trie. */
+ private static final int TRIE_SIZE = 550000;
+
+ /** Space for pattern count trie, must be less than {@link #TRIE_SIZE} and
+ * greater than the number of occurrences of any pattern in the
+ * dictionary. */
+ private static final int TRIEC_SIZE = 260000;
+
+ /** Size of output hash table, should be a multiple of 510. */
+ private static final short MAX_OPS = 4080;
+
+ /** Maximum pattern length. Also maximum length of external representation
+ * of a "letter". */
+ private static final byte MAX_DOT = 15;
+
+ /** Maximum word length. */
+ private static final byte MAX_LEN = 50;
+
+ /** Maximum length of input lines, must be at least {@link #MAX_LEN}. */
+ private static final short MAX_BUF_LEN = 3000;
+
+ /* End of Constants from TeX code. */
+
+ /* Start of struct definitions from TeX code. */
+ private class Opword {
+ int dot;
+ int val;
+ int op;
+ }
+ /* End of struct definitions from TeX code. */
+
+ /* Start of Variables from TeX code. */
+ int patstart;
+ int patfinish;
+ int hyphstart;
+ int hyphfinish;
+ int goodwt;
+ int badwt;
+ int thresh;
+ char[] xord = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char[] xchr = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char[] xclass = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char[] xint = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char[] xdig = new char[DIGITS_SIZE];
+ char[] xext = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char[] xhyf = new char[HYPH_SIZE];
+ char cmax;
+ char[] triec = new char[TRIE_SIZE + 1];
+ int[] triel = new int[TRIE_SIZE + 1];
+ int[] trier = new int[TRIE_SIZE + 1];
+ boolean[] trietaken = new boolean[TRIE_SIZE + 1];
+ char[] triecc = new char[TRIEC_SIZE + 1];
+ int[] triecl = new int[TRIEC_SIZE + 1];
+ int[] triecr = new int[TRIEC_SIZE + 1];
+ boolean[] triectaken = new boolean[TRIEC_SIZE + 1];
+ Opword[] ops = new Opword[MAX_OPS + 1];
+ char[] trieqc = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ int[] trieql = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ int[] trieqr = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ char qmax;
+ char qmaxthresh;
+ int triemax;
+ int triebmax;
+ int triecount;
+ int opcount;
+ char[] pat = new char[MAX_DOT + 1];
+ int patlen;
+ int triecmax;
+ int triecbmax;
+ int trieccount;
+ int trieckmax;
+ int patcount;
+ File dictionary;
+ File patterns;
+ File translate;
+ File patout;
+ File pattmp;
+// char * fname;
+ float badfrac;
+ float denom;
+ float eff;
+ char[] buf = new char[MAX_BUF_LEN + 1];
+ int bufptr;
+ char imax;
+ int lefthyphenmin;
+ int righthyphenmin;
+ int goodpatcount;
+ int badpatcount;
+ int goodcount;
+ int badcount;
+ int misscount;
+ int levelpatterncount;
+ boolean moretocome;
+ char[] word = new char[MAX_LEN + 1];
+ char[] dots = new char[MAX_LEN + 1];
+ char[] dotw = new char[MAX_LEN + 1];
+ int[] hval = new int[MAX_LEN + 1];
+ boolean[] nomore = new boolean[MAX_LEN + 1];
+ int wlen;
+ char wordwt;
+ boolean wtchg;
+ int hyfmin;
+ int hyfmax;
+ int hyflen;
+ char gooddot;
+ char baddot;
+ int dotmin;
+ int dotmax;
+ int dotlen;
+ boolean procesp;
+ boolean hyphp;
+ int patdot;
+ int hyphlevel;
+ char[] filnam = new char[FILENAME_SIZE];
+ int maxpat;
+ int n1;
+ int n2;
+ int n3;
+ int i;
+ int j;
+ int k;
+ int dot1;
+ boolean[] morethislevel = new boolean[MAX_DOT + 1];
+ /* End of Variables from TeX code. */
+
/** The banner printed when the program starts. */
private String banner = "This is the FOray Hyphenation Pattern Generator.";
@@ -128,9 +273,19 @@
if (this.output == null) {
System.out.println("Error: Output cannot be null.");
}
+ patgen();
}
/**
+ * This is where PATGEN actually starts. We initialize the pattern trie, get
+ * |hyph_level| and |pat_len| limits from the terminal, and generate
+ * patterns.
+ */
+ private void patgen() {
+
+ }
+
+ /**
* Command-line interface for the {@link PatternGenerator} class.
* @param args The command-line arguments.
* The arguments are:
Added: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/patgen.c
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/patgen.c (rev 0)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/patgen.c 2007-09-10 18:01:28 UTC (rev 10202)
@@ -0,0 +1,1932 @@
+#define PATGEN
+#include "cpascal.h"
+/* 9999 */
+#define triesize ( 550000L )
+#define triecsize ( 260000L )
+#define maxops ( 4080 )
+#define maxval ( 10 )
+#define maxdot ( 15 )
+#define maxlen ( 50 )
+#define maxbuflen ( 3000 )
+typedef unsigned char ASCIIcode ;
+typedef ASCIIcode textchar ;
+typedef text textfile ;
+typedef unsigned char packedASCIIcode ;
+typedef ASCIIcode internalcode ;
+typedef packedASCIIcode packedinternalcode ;
+typedef char classtype ;
+typedef char digit ;
+typedef char hyftype ;
+typedef unsigned char qindex ;
+typedef integer valtype ;
+typedef integer dottype ;
+typedef integer optype ;
+typedef integer wordindex ;
+typedef integer triepointer ;
+typedef integer triecpointer ;
+typedef struct {
+ dottype dot ;
+ valtype val ;
+ optype op ;
+} opword ;
+dottype patstart, patfinish ;
+valtype hyphstart, hyphfinish ;
+integer goodwt, badwt, thresh ;
+ASCIIcode xord[256] ;
+textchar xchr[256] ;
+classtype xclass[256] ;
+internalcode xint[256] ;
+textchar xdig[10] ;
+textchar xext[256] ;
+textchar xhyf[4] ;
+internalcode cmax ;
+packedinternalcode triec[triesize + 1] ;
+triepointer triel[triesize + 1], trier[triesize + 1] ;
+boolean trietaken[triesize + 1] ;
+packedinternalcode triecc[triecsize + 1] ;
+triecpointer triecl[triecsize + 1], triecr[triecsize + 1] ;
+boolean triectaken[triecsize + 1] ;
+opword ops[maxops + 1] ;
+internalcode trieqc[256] ;
+triepointer trieql[256], trieqr[256] ;
+qindex qmax ;
+qindex qmaxthresh ;
+triepointer triemax ;
+triepointer triebmax ;
+triepointer triecount ;
+optype opcount ;
+internalcode pat[maxdot + 1] ;
+dottype patlen ;
+triecpointer triecmax, triecbmax, trieccount ;
+triecpointer trieckmax ;
+integer patcount ;
+textfile dictionary, patterns, translate, patout, pattmp ;
+char * fname ;
+real badfrac, denom, eff ;
+textchar buf[maxbuflen + 1] ;
+integer bufptr ;
+internalcode imax ;
+dottype lefthyphenmin, righthyphenmin ;
+integer goodpatcount, badpatcount ;
+integer goodcount, badcount, misscount ;
+integer levelpatterncount ;
+boolean moretocome ;
+internalcode word[maxlen + 1] ;
+hyftype dots[maxlen + 1] ;
+digit dotw[maxlen + 1] ;
+valtype hval[maxlen + 1] ;
+boolean nomore[maxlen + 1] ;
+wordindex wlen ;
+digit wordwt ;
+boolean wtchg ;
+wordindex hyfmin, hyfmax, hyflen ;
+hyftype gooddot, baddot ;
+wordindex dotmin, dotmax, dotlen ;
+boolean procesp, hyphp ;
+dottype patdot ;
+valtype hyphlevel ;
+char filnam[9] ;
+valtype maxpat ;
+integer n1, n2, n3 ;
+valtype i ;
+dottype j ;
+dottype k ;
+dottype dot1 ;
+boolean morethislevel[maxdot + 1] ;
+
+#include "patgen.h"
+void
+#ifdef HAVE_PROTOTYPES
+parsearguments ( void )
+#else
+parsearguments ( )
+#endif
+{
+
+#define noptions ( 2 )
+ getoptstruct longoptions[noptions + 1] ;
+ integer getoptreturnval ;
+ cinttype optionindex ;
+ integer currentoption ;
+ currentoption = 0 ;
+ longoptions [currentoption ].name = "help" ;
+ longoptions [currentoption ].hasarg = 0 ;
+ longoptions [currentoption ].flag = 0 ;
+ longoptions [currentoption ].val = 0 ;
+ currentoption = currentoption + 1 ;
+ longoptions [currentoption ].name = "version" ;
+ longoptions [currentoption ].hasarg = 0 ;
+ longoptions [currentoption ].flag = 0 ;
+ longoptions [currentoption ].val = 0 ;
+ currentoption = currentoption + 1 ;
+ longoptions [currentoption ].name = 0 ;
+ longoptions [currentoption ].hasarg = 0 ;
+ longoptions [currentoption ].flag = 0 ;
+ longoptions [currentoption ].val = 0 ;
+ do {
+ getoptreturnval = getoptlongonly ( argc , argv , "" , longoptions ,
+ addressof ( optionindex ) ) ;
+ if ( getoptreturnval == -1 )
+ {
+ ;
+ }
+ else if ( getoptreturnval == '?' )
+ {
+ usage ( "patgen" ) ;
+ }
+ else if ( ( strcmp ( longoptions [optionindex ].name , "help" ) == 0 ) )
+ {
+ usagehelp ( PATGENHELP , nil ) ;
+ }
+ else if ( ( strcmp ( longoptions [optionindex ].name , "version" ) == 0
+ ) )
+ {
+ printversionandexit ( "This is PATGEN, Version 2.3" , nil ,
+ "Frank M. Liang and Peter Breitenlohner" ) ;
+ }
+ } while ( ! ( getoptreturnval == -1 ) ) ;
+ if ( ( optind + 4 != argc ) )
+ {
+ fprintf ( stderr , "%s\n", "patgen: Need exactly four arguments." ) ;
+ usage ( "patgen" ) ;
+ }
+}
+void
+#ifdef HAVE_PROTOTYPES
+initialize ( void )
+#else
+initialize ( )
+#endif
+{
+ integer bad ;
+ textchar i ;
+ ASCIIcode j ;
+ kpsesetprogname ( argv [0 ]) ;
+ parsearguments () ;
+ Fputs ( output , "This is PATGEN, Version 2.3" ) ;
+ fprintf ( output , "%s\n", versionstring ) ;
+ bad = 0 ;
+ if ( 255 < 127 )
+ bad = 1 ;
+ if ( ( 0 != 0 ) || ( 0 != 0 ) )
+ bad = 2 ;
+ if ( ( triecsize < 4096 ) || ( triesize < triecsize ) )
+ bad = 3 ;
+ if ( maxops > triesize )
+ bad = 4 ;
+ if ( maxval > 10 )
+ bad = 5 ;
+ if ( maxbuflen < maxlen )
+ bad = 6 ;
+ if ( bad > 0 )
+ {
+ fprintf ( stderr , "%s%ld\n", "Bad constants---case " , (long)bad ) ;
+ uexit ( 1 ) ;
+ }
+ {register integer for_end; j = 0 ;for_end = 255 ; if ( j <= for_end) do
+ xchr [j ]= ' ' ;
+ while ( j++ < for_end ) ;}
+ xchr [46 ]= '.' ;
+ xchr [48 ]= '0' ;
+ xchr [49 ]= '1' ;
+ xchr [50 ]= '2' ;
+ xchr [51 ]= '3' ;
+ xchr [52 ]= '4' ;
+ xchr [53 ]= '5' ;
+ xchr [54 ]= '6' ;
+ xchr [55 ]= '7' ;
+ xchr [56 ]= '8' ;
+ xchr [57 ]= '9' ;
+ xchr [65 ]= 'A' ;
+ xchr [66 ]= 'B' ;
+ xchr [67 ]= 'C' ;
+ xchr [68 ]= 'D' ;
+ xchr [69 ]= 'E' ;
+ xchr [70 ]= 'F' ;
+ xchr [71 ]= 'G' ;
+ xchr [72 ]= 'H' ;
+ xchr [73 ]= 'I' ;
+ xchr [74 ]= 'J' ;
+ xchr [75 ]= 'K' ;
+ xchr [76 ]= 'L' ;
+ xchr [77 ]= 'M' ;
+ xchr [78 ]= 'N' ;
+ xchr [79 ]= 'O' ;
+ xchr [80 ]= 'P' ;
+ xchr [81 ]= 'Q' ;
+ xchr [82 ]= 'R' ;
+ xchr [83 ]= 'S' ;
+ xchr [84 ]= 'T' ;
+ xchr [85 ]= 'U' ;
+ xchr [86 ]= 'V' ;
+ xchr [87 ]= 'W' ;
+ xchr [88 ]= 'X' ;
+ xchr [89 ]= 'Y' ;
+ xchr [90 ]= 'Z' ;
+ xchr [97 ]= 'a' ;
+ xchr [98 ]= 'b' ;
+ xchr [99 ]= 'c' ;
+ xchr [100 ]= 'd' ;
+ xchr [101 ]= 'e' ;
+ xchr [102 ]= 'f' ;
+ xchr [103 ]= 'g' ;
+ xchr [104 ]= 'h' ;
+ xchr [105 ]= 'i' ;
+ xchr [106 ]= 'j' ;
+ xchr [107 ]= 'k' ;
+ xchr [108 ]= 'l' ;
+ xchr [109 ]= 'm' ;
+ xchr [110 ]= 'n' ;
+ xchr [111 ]= 'o' ;
+ xchr [112 ]= 'p' ;
+ xchr [113 ]= 'q' ;
+ xchr [114 ]= 'r' ;
+ xchr [115 ]= 's' ;
+ xchr [116 ]= 't' ;
+ xchr [117 ]= 'u' ;
+ xchr [118 ]= 'v' ;
+ xchr [119 ]= 'w' ;
+ xchr [120 ]= 'x' ;
+ xchr [121 ]= 'y' ;
+ xchr [122 ]= 'z' ;
+ {register integer for_end; i = chr ( 0 ) ;for_end = chr ( 255 ) ; if ( i
+ <= for_end) do
+ xord [i ]= 0 ;
+ while ( i++ < for_end ) ;}
+ {register integer for_end; j = 0 ;for_end = 255 ; if ( j <= for_end) do
+ xord [xchr [j ]]= j ;
+ while ( j++ < for_end ) ;}
+ xord [' ' ]= 32 ;
+ xord [chr ( 9 ) ]= 32 ;
+ {register integer for_end; i = chr ( 0 ) ;for_end = chr ( 255 ) ; if ( i
+ <= for_end) do
+ {
+ xclass [i ]= 5 ;
+ xint [i ]= 0 ;
+ }
+ while ( i++ < for_end ) ;}
+ xclass [' ' ]= 0 ;
+ {register integer for_end; j = 0 ;for_end = 255 ; if ( j <= for_end) do
+ xext [j ]= ' ' ;
+ while ( j++ < for_end ) ;}
+ xext [1 ]= '.' ;
+ {register integer for_end; j = 0 ;for_end = 9 ; if ( j <= for_end) do
+ {
+ xdig [j ]= xchr [j + 48 ];
+ xclass [xdig [j ]]= 1 ;
+ xint [xdig [j ]]= j ;
+ }
+ while ( j++ < for_end ) ;}
+ xhyf [1 ]= '.' ;
+ xhyf [2 ]= '-' ;
+ xhyf [3 ]= '*' ;
+}
+ASCIIcode
+#ifdef HAVE_PROTOTYPES
+zgetASCII ( textchar c )
+#else
+zgetASCII ( c )
+ textchar c ;
+#endif
+{
+ /* 40 */ register ASCIIcode Result; ASCIIcode i ;
+ i = xord [c ];
+ if ( i == 0 )
+ {
+ while ( i < 255 ) {
+
+ i = i + 1 ;
+ if ( ( xchr [i ]== ' ' ) && ( i != 32 ) )
+ goto lab40 ;
+ }
+ {
+ fprintf ( stderr , "%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" , (long)256 , " characters" , "]." ) ;
+ uexit ( 1 ) ;
+ }
+ lab40: xord [c ]= i ;
+ xchr [i ]= c ;
+ }
+ Result = i ;
+ return Result ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+initpatterntrie ( void )
+#else
+initpatterntrie ( )
+#endif
+{
+ internalcode c ;
+ optype h ;
+ {register integer for_end; c = 0 ;for_end = 255 ; if ( c <= for_end) do
+ {
+ triec [1 + c ]= c ;
+ triel [1 + c ]= 0 ;
+ trier [1 + c ]= 0 ;
+ trietaken [1 + c ]= false ;
+ }
+ while ( c++ < for_end ) ;}
+ trietaken [1 ]= true ;
+ triebmax = 1 ;
+ triemax = 256 ;
+ triecount = 256 ;
+ qmaxthresh = 5 ;
+ triel [0 ]= triemax + 1 ;
+ trier [triemax + 1 ]= 0 ;
+ {register integer for_end; h = 1 ;for_end = maxops ; if ( h <= for_end) do
+ ops [h ].val = 0 ;
+ while ( h++ < for_end ) ;}
+ opcount = 0 ;
+}
+triepointer
+#ifdef HAVE_PROTOTYPES
+firstfit ( void )
+#else
+firstfit ( )
+#endif
+{
+ /* 40 41 */ register triepointer Result; triepointer s, t ;
+ qindex q ;
+ if ( qmax > qmaxthresh )
+ t = trier [triemax + 1 ];
+ else t = 0 ;
+ while ( true ) {
+
+ t = triel [t ];
+ s = t - trieqc [1 ];
+ if ( s > triesize - 256 )
+ {
+ fprintf ( stderr , "%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" , (long)triesize , " pattern trie nodes" , "]." ) ;
+ uexit ( 1 ) ;
+ }
+ while ( triebmax < s ) {
+
+ triebmax = triebmax + 1 ;
+ trietaken [triebmax ]= false ;
+ triec [triebmax + 255 ]= 0 ;
+ triel [triebmax + 255 ]= triebmax + 256 ;
+ trier [triebmax + 256 ]= triebmax + 255 ;
+ }
+ if ( trietaken [s ])
+ goto lab41 ;
+ {register integer for_end; q = qmax ;for_end = 2 ; if ( q >= for_end) do
+ if ( triec [s + trieqc [q ]]!= 0 )
+ goto lab41 ;
+ while ( q-- > for_end ) ;}
+ goto lab40 ;
+ lab41: ;
+ }
+ lab40: ;
+ {register integer for_end; q = 1 ;for_end = qmax ; if ( q <= for_end) do
+ {
+ t = s + trieqc [q ];
+ triel [trier [t ]]= triel [t ];
+ trier [triel [t ]]= trier [t ];
+ triec [t ]= trieqc [q ];
+ triel [t ]= trieql [q ];
+ trier [t ]= trieqr [q ];
+ if ( t > triemax )
+ triemax = t ;
+ }
+ while ( q++ < for_end ) ;}
+ trietaken [s ]= true ;
+ Result = s ;
+ return Result ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+zunpack ( triepointer s )
+#else
+zunpack ( s )
+ triepointer s ;
+#endif
+{
+ internalcode c ;
+ triepointer t ;
+ qmax = 1 ;
+ {register integer for_end; c = 1 ;for_end = cmax ; if ( c <= for_end) do
+ {
+ t = s + c ;
+ if ( triec [t ]== c )
+ {
+ trieqc [qmax ]= c ;
+ trieql [qmax ]= triel [t ];
+ trieqr [qmax ]= trier [t ];
+ qmax = qmax + 1 ;
+ trier [triel [0 ]]= t ;
+ triel [t ]= triel [0 ];
+ triel [0 ]= t ;
+ trier [t ]= 0 ;
+ triec [t ]= 0 ;
+ }
+ }
+ while ( c++ < for_end ) ;}
+ trietaken [s ]= false ;
+}
+optype
+#ifdef HAVE_PROTOTYPES
+znewtrieop ( valtype v , dottype d , optype n )
+#else
+znewtrieop ( v , d , n )
+ valtype v ;
+ dottype d ;
+ optype n ;
+#endif
+{
+ /* 10 */ register optype Result; optype h ;
+ h = ( ( n + 313 * d + 361 * v ) % maxops ) + 1 ;
+ while ( true ) {
+
+ if ( ops [h ].val == 0 )
+ {
+ opcount = opcount + 1 ;
+ if ( opcount == maxops )
+ {
+ fprintf ( stderr , "%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" , (long)maxops , " outputs" , "]." ) ;
+ uexit ( 1 ) ;
+ }
+ ops [h ].val = v ;
+ ops [h ].dot = d ;
+ ops [h ].op = n ;
+ Result = h ;
+ goto lab10 ;
+ }
+ if ( ( ops [h ].val == v ) && ( ops [h ].dot == d ) && ( ops [h ].op
+ == n ) )
+ {
+ Result = h ;
+ goto lab10 ;
+ }
+ if ( h > 1 )
+ h = h - 1 ;
+ else h = maxops ;
+ }
+ lab10: ;
+ return Result ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+zinsertpattern ( valtype val , dottype dot )
+#else
+zinsertpattern ( val , dot )
+ valtype val ;
+ dottype dot ;
+#endif
+{
+ dottype i ;
+ triepointer s, t ;
+ i = 1 ;
+ s = 1 + pat [i ];
+ t = triel [s ];
+ while ( ( t > 0 ) && ( i < patlen ) ) {
+
+ i = i + 1 ;
+ t = t + pat [i ];
+ if ( triec [t ]!= pat [i ])
+ {
+ if ( triec [t ]== 0 )
+ {
+ triel [trier [t ]]= triel [t ];
+ trier [triel [t ]]= trier [t ];
+ triec [t ]= pat [i ];
+ triel [t ]= 0 ;
+ trier [t ]= 0 ;
+ if ( t > triemax )
+ triemax = t ;
+ }
+ else {
+
+ unpack ( t - pat [i ]) ;
+ trieqc [qmax ]= pat [i ];
+ trieql [qmax ]= 0 ;
+ trieqr [qmax ]= 0 ;
+ t = firstfit () ;
+ triel [s ]= t ;
+ t = t + pat [i ];
+ }
+ triecount = triecount + 1 ;
+ }
+ s = t ;
+ t = triel [s ];
+ }
+ trieql [1 ]= 0 ;
+ trieqr [1 ]= 0 ;
+ qmax = 1 ;
+ while ( i < patlen ) {
+
+ i = i + 1 ;
+ trieqc [1 ]= pat [i ];
+ t = firstfit () ;
+ triel [s ]= t ;
+ s = t + pat [i ];
+ triecount = triecount + 1 ;
+ }
+ trier [s ]= newtrieop ( val , dot , trier [s ]) ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+initcounttrie ( void )
+#else
+initcounttrie ( )
+#endif
+{
+ internalcode c ;
+ {register integer for_end; c = 0 ;for_end = 255 ; if ( c <= for_end) do
+ {
+ triecc [1 + c ]= c ;
+ triecl [1 + c ]= 0 ;
+ triecr [1 + c ]= 0 ;
+ triectaken [1 + c ]= false ;
+ }
+ while ( c++ < for_end ) ;}
+ triectaken [1 ]= true ;
+ triecbmax = 1 ;
+ triecmax = 256 ;
+ trieccount = 256 ;
+ trieckmax = 4096 ;
+ triecl [0 ]= triecmax + 1 ;
+ triecr [triecmax + 1 ]= 0 ;
+ patcount = 0 ;
+}
+triecpointer
+#ifdef HAVE_PROTOTYPES
+firstcfit ( void )
+#else
+firstcfit ( )
+#endif
+{
+ /* 40 41 */ register triecpointer Result; triecpointer a, b ;
+ qindex q ;
+ if ( qmax > 3 )
+ a = triecr [triecmax + 1 ];
+ else a = 0 ;
+ while ( true ) {
+
+ a = triecl [a ];
+ b = a - trieqc [1 ];
+ if ( b > trieckmax - 256 )
+ {
+ if ( trieckmax == triecsize )
+ {
+ fprintf ( stderr , "%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" , (long)triecsize , " count trie nodes" , "]." ) ;
+ uexit ( 1 ) ;
+ }
+ fprintf ( output , "%ld%s", (long)trieckmax / 1024 , "K " ) ;
+ if ( trieckmax > triecsize - 4096 )
+ trieckmax = triecsize ;
+ else trieckmax = trieckmax + 4096 ;
+ }
+ while ( triecbmax < b ) {
+
+ triecbmax = triecbmax + 1 ;
+ triectaken [triecbmax ]= false ;
+ triecc [triecbmax + 255 ]= 0 ;
+ triecl [triecbmax + 255 ]= triecbmax + 256 ;
+ triecr [triecbmax + 256 ]= triecbmax + 255 ;
+ }
+ if ( triectaken [b ])
+ goto lab41 ;
+ {register integer for_end; q = qmax ;for_end = 2 ; if ( q >= for_end) do
+ if ( triecc [b + trieqc [q ]]!= 0 )
+ goto lab41 ;
+ while ( q-- > for_end ) ;}
+ goto lab40 ;
+ lab41: ;
+ }
+ lab40: ;
+ {register integer for_end; q = 1 ;for_end = qmax ; if ( q <= for_end) do
+ {
+ a = b + trieqc [q ];
+ triecl [triecr [a ]]= triecl [a ];
+ triecr [triecl [a ]]= triecr [a ];
+ triecc [a ]= trieqc [q ];
+ triecl [a ]= trieql [q ];
+ triecr [a ]= trieqr [q ];
+ if ( a > triecmax )
+ triecmax = a ;
+ }
+ while ( q++ < for_end ) ;}
+ triectaken [b ]= true ;
+ Result = b ;
+ return Result ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+zunpackc ( triecpointer b )
+#else
+zunpackc ( b )
+ triecpointer b ;
+#endif
+{
+ internalcode c ;
+ triecpointer a ;
+ qmax = 1 ;
+ {register integer for_end; c = 1 ;for_end = cmax ; if ( c <= for_end) do
+ {
+ a = b + c ;
+ if ( triecc [a ]== c )
+ {
+ trieqc [qmax ]= c ;
+ trieql [qmax ]= triecl [a ];
+ trieqr [qmax ]= triecr [a ];
+ qmax = qmax + 1 ;
+ triecr [triecl [0 ]]= a ;
+ triecl [a ]= triecl [0 ];
+ triecl [0 ]= a ;
+ triecr [a ]= 0 ;
+ triecc [a ]= 0 ;
+ }
+ }
+ while ( c++ < for_end ) ;}
+ triectaken [b ]= false ;
+}
+triecpointer
+#ifdef HAVE_PROTOTYPES
+zinsertcpat ( wordindex fpos )
+#else
+zinsertcpat ( fpos )
+ wordindex fpos ;
+#endif
+{
+ register triecpointer Result; wordindex spos ;
+ triecpointer a, b ;
+ spos = fpos - patlen ;
+ spos = spos + 1 ;
+ b = 1 + word [spos ];
+ a = triecl [b ];
+ while ( ( a > 0 ) && ( spos < fpos ) ) {
+
+ spos = spos + 1 ;
+ a = a + word [spos ];
+ if ( triecc [a ]!= word [spos ])
+ {
+ if ( triecc [a ]== 0 )
+ {
+ triecl [triecr [a ]]= triecl [a ];
+ triecr [triecl [a ]]= triecr [a ];
+ triecc [a ]= word [spos ];
+ triecl [a ]= 0 ;
+ triecr [a ]= 0 ;
+ if ( a > triecmax )
+ triecmax = a ;
+ }
+ else {
+
+ unpackc ( a - word [spos ]) ;
+ trieqc [qmax ]= word [spos ];
+ trieql [qmax ]= 0 ;
+ trieqr [qmax ]= 0 ;
+ a = firstcfit () ;
+ triecl [b ]= a ;
+ a = a + word [spos ];
+ }
+ trieccount = trieccount + 1 ;
+ }
+ b = a ;
+ a = triecl [a ];
+ }
+ trieql [1 ]= 0 ;
+ trieqr [1 ]= 0 ;
+ qmax = 1 ;
+ while ( spos < fpos ) {
+
+ spos = spos + 1 ;
+ trieqc [1 ]= word [spos ];
+ a = firstcfit () ;
+ triecl [b ]= a ;
+ b = a + word [spos ];
+ trieccount = trieccount + 1 ;
+ }
+ Result = b ;
+ patcount = patcount + 1 ;
+ return Result ;
+}
+void
+#ifdef HAVE_PROTOTYPES
+readtranslate ( void )
+#else
+readtranslate ( )
+#endif
+{
+ /* 30 */ textchar c ;
+ integer n ;
+ ASCIIcode j ;
+ boolean bad ;
+ boolean lower ;
+ dottype i ;
+ triepointer s, t ;
+ imax = 1 ;
+ fname = cmdline ( 4 ) ;
+ reset ( translate , fname ) ;
+ if ( eof ( translate ) )
+ {
+ lefthyphenmin = 2 ;
+ righthyphenmin = 3 ;
+ {register integer for_end; j = 65 ;for_end = 90 ; if ( j <= for_end) do
+ {
+ imax = imax + 1 ;
+ c = xchr [j + 32 ];
+ xclass [c ]= 3 ;
+ xint [c ]= imax ;
+ xext [imax ]= c ;
+ c = xchr [j ];
+ xclass [c ]= 3 ;
+ xint [c ]= imax ;
+ }
+ while ( j++ < for_end ) ;}
+ }
+ else {
+
+ {
+ bufptr = 0 ;
+ while ( ! eoln ( translate ) ) {
+
+ if ( ( bufptr >= maxbuflen ) )
+ {
+ {
+ bufptr = 0 ;
+ do {
+ bufptr = bufptr + 1 ;
+ putc ( buf [bufptr ], output );
+ } while ( ! ( bufptr == maxbuflen ) ) ;
+ fprintf ( output , "%c\n", ' ' ) ;
+ }
+ {
+ fprintf ( stderr , "%s\n", "Line too long" ) ;
+ uexit ( 1 ) ;
+ }
+ }
+ bufptr = bufptr + 1 ;
+ read ( translate , buf [bufptr ]) ;
+ }
+ readln ( translate ) ;
+ while ( bufptr < maxbuflen ) {
+
+ bufptr = bufptr + 1 ;
+ buf [bufptr ]= ' ' ;
+ }
+ }
+ bad = false ;
+ if ( buf [1 ]== ' ' )
+ n = 0 ;
+ else if ( xclass [buf [1 ]]== 1 )
+ n = xint [buf [1 ]];
+ else bad = true ;
+ if ( xclass [buf [2 ]]== 1 )
+ n = 10 * n + xint [buf [2 ]];
+ else bad = true ;
+ if ( ( n >= 1 ) && ( n < maxdot ) )
+ lefthyphenmin = n ;
+ else bad = true ;
+ if ( buf [3 ]== ' ' )
+ n = 0 ;
+ else if ( xclass [buf [3 ]]== 1 )
+ n = xint [buf [3 ]];
+ else bad = true ;
+ if ( xclass [buf [4 ]]== 1 )
+ n = 10 * n + xint [buf [4 ]];
+ else bad = true ;
+ if ( ( n >= 1 ) && ( n < maxdot ) )
+ righthyphenmin = n ;
+ else bad = true ;
+ if ( bad )
+ {
+ bad = false ;
+ do {
+ Fputs ( output , "left_hyphen_min, right_hyphen_min: " ) ;
+ input2ints ( n1 , n2 ) ;
+ if ( ( n1 >= 1 ) && ( n1 < maxdot ) && ( n2 >= 1 ) && ( n2 < maxdot )
+ )
+ {
+ lefthyphenmin = n1 ;
+ righthyphenmin = n2 ;
+ }
+ else {
+
+ n1 = 0 ;
+ fprintf ( output , "%s%ld%s\n", "Specify 1<=left_hyphen_min,right_hyphen_min<=" , (long)maxdot - 1 , " !" ) ;
+ }
+ } while ( ! ( n1 > 0 ) ) ;
+ }
+ {register integer for_end; j = 1 ;for_end = 3 ; if ( j <= for_end) do
+ {
+ if ( buf [j + 4 ]!= ' ' )
+ xhyf [j ]= buf [j + 4 ];
+ if ( xclass [xhyf [j ]]== 5 )
+ xclass [xhyf [j ]]= 2 ;
+ else bad = true ;
+ }
+ while ( j++ < for_end ) ;}
+ xclass ['.' ]= 2 ;
+ if ( bad )
+ {
+ {
+ bufptr = 0 ;
+ do {
+ bufptr = bufptr + 1 ;
+ putc ( buf [bufptr ], output );
+ } while ( ! ( bufptr == maxbuflen ) ) ;
+ fprintf ( output , "%c\n", ' ' ) ;
+ }
+ {
+ fprintf ( stderr , "%s\n", "Bad hyphenation data" ) ;
+ uexit ( 1 ) ;
+ }
+ }
+ cmax = 254 ;
+ while ( ! eof ( translate ) ) {
+
+ {
+ bufptr = 0 ;
+ while ( ! eoln ( translate ) ) {
+
+ if ( ( bufptr >= maxbuflen ) )
+ {
+ {
+ bufptr = 0 ;
+ do {
+ bufptr = bufptr + 1 ;
+ putc ( buf [bufptr ], output );
+ } while ( ! ( bufptr == maxbuflen ) ) ;
+ fprintf ( output , "%c\n", ' ' ) ;
+ }
+ {
+ fprintf ( stderr , "%s\n", "Line too long" ) ;
+ uexit ( 1 ) ;
+ }
+ }
+ bufptr = bufptr + 1 ;
+ read ( translate , buf [bufptr ]) ;
+ }
+ readln ( translate ) ;
+ while ( bufptr < maxbuflen ) {
+
+ bufptr = bufptr + 1 ;
+ buf [bufptr ]= ' ' ;
+ }
+ }
+ bufptr = 1 ;
+ lower = true ;
+ while ( ! bad ) {
+
+ patlen = 0 ;
+ do {
+ if ( bufptr < maxbuflen )
+ bufptr = bufptr + 1 ;
+ else bad = true ;
+ if ( buf [bufptr ]== buf [1 ])
+ if ( patlen == 0 )
+ goto lab30 ;
+ else {
+
+ if ( lower )
+ {
+ if ( imax == 255 )
+ {
+ {
+ bufptr = 0 ;
+ do {
+ bufptr = bufptr + 1 ;
+ putc ( buf [bufptr ], output );
+ } while ( ! ( bufptr == maxbuflen ) ) ;
+ fprintf ( output , "%c\n", ' ' ) ;
+ }
+ {
+ fprintf ( stderr , "%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" , (long)256 , " letters" , "]." ) ;
+ uexit ( 1 ) ;
+ }
+ }
+ imax = imax + 1 ;
+ xext [imax ]= xchr [pat [patlen ]];
+ }
+ c = xchr [pat [1 ]];
+ if ( patlen == 1 )
+ {
+ if ( xclass [c ]!= 5 )
+ bad = true ;
+ xclass [c ]= 3 ;
+ xint [c ]= imax ;
+ }
+ else {
+
+ if ( xclass [c ]== 5 )
+ xclass [c ]= 4 ;
+ if ( xclass [c ]!= 4 )
+ bad = true ;
+ i = 0 ;
+ s = 1 ;
+ t = triel [s ];
+ while ( ( t > 1 ) && ( i < patlen ) ) {
+
+ i = i + 1 ;
+ t = t + pat [i ];
+ if ( triec [t ]!= pat [i ])
+ {
+ if ( triec [t ]== 0 )
+ {
+ triel [trier [t ]]= triel [t ];
+ trier [triel [t ]]= trier [t ];
+ triec [t ]= pat [i ];
+ triel [t ]= 0 ;
+ trier [t ]= 0 ;
+ if ( t > triemax )
+ triemax = t ;
+ }
+ else {
+
+ unpack ( t - pat [i ]) ;
+ trieqc [qmax ]= pat [i ];
+ trieql [qmax ]= 0 ;
+ trieqr [qmax ]= 0 ;
+ t = firstfit () ;
+ triel [s ]= t ;
+ t = t + pat [i ];
+ }
+ triecount = triecount + 1 ;
+ }
+ else if ( trier [t ]> 0 )
+ bad = true ;
+ s = t ;
+ t = triel [s ];
+ }
+ if ( t > 1 )
+ bad = true ;
+ trieql [1 ]= 0 ;
+ trieqr [1 ]= 0 ;
+ qmax = 1 ;
+ while ( i < patlen ) {
+
+ i = i + 1 ;
+ trieqc [1 ]= pat [i ];
+ t = firstfit () ;
+ triel [s ]= t ;
+ s = t + pat [i ];
+ triecount = triecount + 1 ;
+ }
+ trier [s ]= imax ;
+ if ( ! lower )
+ triel [s ]= 1 ;
+ }
+ }
+ else if ( patlen == maxdot )
+ bad = true ;
+ else {
+
+ patlen = patlen + 1 ;
+ pat [patlen ]= getASCII ( buf [bufptr ]) ;
+ }
+ } while ( ! ( ( buf [bufptr ]== buf [1 ]) || bad ) ) ;
+ lower = false ;
+ }
+ lab30: if ( bad )
+ {
+ {
+ bufptr = 0 ;
+ do {
+ bufptr = bufptr + 1 ;
+ putc ( buf [bufptr ],...
[truncated message content] |
|
From: <vic...@us...> - 2007-09-25 17:46:13
|
Revision: 10214
http://foray.svn.sourceforge.net/foray/?rev=10214&view=rev
Author: victormote
Date: 2007-09-25 10:46:16 -0700 (Tue, 25 Sep 2007)
Log Message:
-----------
Add test for line centering.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
Added Paths:
-----------
trunk/foray/resource/test/fo/block-003.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-17 15:35:13 UTC (rev 10213)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-25 17:46:16 UTC (rev 10214)
@@ -34,6 +34,7 @@
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
import org.foray.area.PageCollection;
+import org.foray.area.TextArea;
import org.foray.core.FOrayException;
/**
@@ -215,4 +216,63 @@
assertEquals(testString, documentContent);
}
+ /**
+ * Test of fo/block-003.fo.
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testBlock003() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/block-003.fo");
+ final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
+ areaTree);
+
+ /* Test location and dimensions of the block area. */
+ AreaNode node = firstNormalFlowArea.getChildAt(0);
+ assertTrue(node instanceof NormalBlockArea);
+ final NormalBlockArea blockArea = (NormalBlockArea) node;
+ /* 1 inch left margin. */
+ assertEquals(72000, blockArea.crOriginX());
+ /* 10 inches from bottom (11 inches high, 1 inch top margin). */
+ assertEquals(720000, blockArea.crOriginY());
+ /* Page is 8.5 inches wide, with 2 inches total margin.
+ * 6.5 * 72,000 = 468,000. */
+ assertEquals(468000, blockArea.crIpd());
+
+ /* Test location and dimensions of the line area. */
+ node = blockArea.getChildAt(0);
+ assertTrue(node instanceof LineArea);
+ final LineArea lineArea = (LineArea) node;
+ /* x same as the parent block. */
+ assertEquals(72000, lineArea.crOriginX());
+ /* y adjusted for half-leading = 12,000 * .2 * .5 = 1200. */
+ assertEquals(718800, lineArea.crOriginY());
+ /* ipd same as parent block. */
+ assertEquals(468000, lineArea.crIpd());
+
+ /* Test location and dimensions of the text area. The key thing we are
+ * testing here is that IT IS CENTERED. */
+ node = lineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea = (TextArea) node;
+
+ /* The text is "Test of Centering". From the Helvetica AFM file, the
+ * widths are as follows: T(611) + e(556) + s(500) + t(278) + space(278)
+ * + o(556) + f(278) + space(278) + C(722) + e(556) + n(556) + t(278)
+ * + e(556) + r(333) + i(222) + n(556) + g(556) = 7,670. If these are
+ * scaled to 12 points, the millipoints used are 7670 * 12 = 92,040. */
+ assertEquals(92040, textArea.crIpd());
+
+ /* The x value of the text area content rectangle should be at the x
+ * location of the parent line area + 1/2 of the unused area in the
+ * line. Total line area ipd = 468,000. Unused line area ipd =
+ * 468,000 - 92,040 = 375,960. One half of the unused line area ipd =
+ * 187,980. x = 72,000 + 187,980 = 259,980. */
+ assertEquals(259980, textArea.crOriginX());
+
+ /* The y value of the text area content rectangle should be the same as
+ * the parent line area. */
+ assertEquals(718800, textArea.crOriginY());
+ }
+
}
Added: trunk/foray/resource/test/fo/block-003.fo
===================================================================
--- trunk/foray/resource/test/fo/block-003.fo (rev 0)
+++ trunk/foray/resource/test/fo/block-003.fo 2007-09-25 17:46:16 UTC (rev 10214)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo tests basic centering of content on a line.
+-->
+
+<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 font-family="sans-serif" font-size="12pt" text-align="center">Test of
+Centering</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-09-28 19:46:44
|
Revision: 10215
http://foray.svn.sourceforge.net/foray/?rev=10215&view=rev
Author: victormote
Date: 2007-09-28 12:46:47 -0700 (Fri, 28 Sep 2007)
Log Message:
-----------
Add unimplemented test for centered text with word-spacing.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
Added Paths:
-----------
trunk/foray/resource/test/fo/block-004.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-25 17:46:16 UTC (rev 10214)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-28 19:46:47 UTC (rev 10215)
@@ -218,6 +218,7 @@
/**
* Test of fo/block-003.fo.
+ * This is a test of simple centering of a text-area on a line.
* @throws FOrayException For errors creating the FO Tree or Area Tree.
*/
public void testBlock003() throws FOrayException {
@@ -256,11 +257,17 @@
assertTrue(node instanceof TextArea);
final TextArea textArea = (TextArea) node;
- /* The text is "Test of Centering". From the Helvetica AFM file, the
- * widths are as follows: T(611) + e(556) + s(500) + t(278) + space(278)
- * + o(556) + f(278) + space(278) + C(722) + e(556) + n(556) + t(278)
- * + e(556) + r(333) + i(222) + n(556) + g(556) = 7,670. If these are
- * scaled to 12 points, the millipoints used are 7670 * 12 = 92,040. */
+ /* The text is "Test of Centering".
+ * From the Helvetica AFM file, the widths are as follows:
+ * T(611) + e(556) + s(500) + t(278)
+ * + space(278)
+ * + o(556) + f(278)
+ * + space(278)
+ * + C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + i(222)
+ * + n(556) + g(556)
+ * = 7,670.
+ * If these are scaled to 12 points, the millipoints used are 7670 * 12
+ * = 92,040. */
assertEquals(92040, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
@@ -275,4 +282,76 @@
assertEquals(718800, textArea.crOriginY());
}
+ /**
+ * Test of fo/block-004.fo.
+ * This is a test of centering of a text-area on a line, where the text-area
+ * has word-spacing = ".3em".
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testBlock004() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/block-004.fo");
+ final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
+ areaTree);
+
+ /* Test location and dimensions of the block area. */
+ AreaNode node = firstNormalFlowArea.getChildAt(0);
+ assertTrue(node instanceof NormalBlockArea);
+ final NormalBlockArea blockArea = (NormalBlockArea) node;
+ /* 1 inch left margin. */
+ assertEquals(72000, blockArea.crOriginX());
+ /* 10 inches from bottom (11 inches high, 1 inch top margin). */
+ assertEquals(720000, blockArea.crOriginY());
+ /* Page is 8.5 inches wide, with 2 inches total margin.
+ * 6.5 * 72,000 = 468,000. */
+ assertEquals(468000, blockArea.crIpd());
+
+ /* Test location and dimensions of the line area. */
+ node = blockArea.getChildAt(0);
+ assertTrue(node instanceof LineArea);
+ final LineArea lineArea = (LineArea) node;
+ /* x same as the parent block. */
+ assertEquals(72000, lineArea.crOriginX());
+ /* y adjusted for half-leading = 12,000 * .2 * .5 = 1200. */
+ assertEquals(718800, lineArea.crOriginY());
+ /* ipd same as parent block. */
+ assertEquals(468000, lineArea.crIpd());
+
+ /* Test location and dimensions of the text area. The key thing we are
+ * testing here is that IT IS CENTERED. */
+ node = lineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea = (TextArea) node;
+
+ /* The text is "Centered with Word Spacing".
+ * From the Helvetica AFM file, the widths are as follows:
+ * C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + e(556) + d(556)
+ * + space(278)
+ * + w(722) + i(222) + t(278) + h(556)
+ * + space(278)
+ * + W(944) + o(556) + r(333) + d(556)
+ * + space(278)
+ * + S(556) + p(556) + a(556) + c(500) + i(222) + n(556) + g(556)
+ * = 12,616.
+ * If these are scaled to 12 points, the millipoints used are 12,616
+ * * 12 = 151,392.
+ * The extra word spacing is .3em = .3 * 12000 * 3 occurrences = 10,800.
+ * Total ipd of text-area = 151,392 + 10,800 = */
+
+ /* TODO: Turn these tests back on after the code has been fixed. */
+// assertEquals(162192, textArea.crIpd());
+
+ /* The x value of the text area content rectangle should be at the x
+ * location of the parent line area + 1/2 of the unused area in the
+ * line. Total line area ipd = 468,000. Unused line area ipd =
+ * 468,000 - 92,040 = 375,960. One half of the unused line area ipd =
+ * 187,980. x = 72,000 + 187,980 = 259,980. */
+// assertEquals(259980, textArea.crOriginX());
+
+ /* The y value of the text area content rectangle should be the same as
+ * the parent line area. */
+ assertEquals(718800, textArea.crOriginY());
+ }
+
}
Added: trunk/foray/resource/test/fo/block-004.fo
===================================================================
--- trunk/foray/resource/test/fo/block-004.fo (rev 0)
+++ trunk/foray/resource/test/fo/block-004.fo 2007-09-28 19:46:47 UTC (rev 10215)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo tests centering of a text-area a line, where the text-area has word
+spacing.
+-->
+
+<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 font-family="sans-serif" font-size="12pt" text-align="center"
+word-spacing=".3em">Centered with Word Spacing</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-09-30 12:13:41
|
Revision: 10220
http://foray.svn.sourceforge.net/foray/?rev=10220&view=rev
Author: victormote
Date: 2007-09-30 05:13:35 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
Update version numbers in preparation for a release.
Modified Paths:
--------------
trunk/foray/foray-core/src/java/org/foray/core/Application.java
trunk/foray/scripts/build-common.xml
trunk/foray/scripts/dist-test.sh
Modified: trunk/foray/foray-core/src/java/org/foray/core/Application.java
===================================================================
--- trunk/foray/foray-core/src/java/org/foray/core/Application.java 2007-09-30 11:59:56 UTC (rev 10219)
+++ trunk/foray/foray-core/src/java/org/foray/core/Application.java 2007-09-30 12:13:35 UTC (rev 10220)
@@ -64,7 +64,7 @@
* @return The current version of the application.
*/
public static String getVersion() {
- return "0.3-dev";
+ return "0.3";
}
/**
Modified: trunk/foray/scripts/build-common.xml
===================================================================
--- trunk/foray/scripts/build-common.xml 2007-09-30 11:59:56 UTC (rev 10219)
+++ trunk/foray/scripts/build-common.xml 2007-09-30 12:13:35 UTC (rev 10220)
@@ -38,7 +38,7 @@
<property name="name.lowercase" value="foray"/>
<property name="contact.info"
value="The FOray project http://www.foray.org"/>
- <property name="version" value="0.3-dev"/>
+ <property name="version" value="0.3"/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="off"/>
Modified: trunk/foray/scripts/dist-test.sh
===================================================================
--- trunk/foray/scripts/dist-test.sh 2007-09-30 11:59:56 UTC (rev 10219)
+++ trunk/foray/scripts/dist-test.sh 2007-09-30 12:13:35 UTC (rev 10220)
@@ -5,7 +5,7 @@
# Modify the following variable to the appropriate value before running this
# script.
-FORAY_VERSION="0.2"
+FORAY_VERSION="0.3"
TEMP_DIR=$HOME/tmp
UNZIP_DIR=$TEMP_DIR/unzip
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-09-30 16:15:42
|
Revision: 10225
http://foray.svn.sourceforge.net/foray/?rev=10225&view=rev
Author: victormote
Date: 2007-09-30 09:15:45 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
Upgrade version numbers for development.
Modified Paths:
--------------
trunk/foray/foray-core/src/java/org/foray/core/Application.java
trunk/foray/scripts/build-common.xml
Modified: trunk/foray/foray-core/src/java/org/foray/core/Application.java
===================================================================
--- trunk/foray/foray-core/src/java/org/foray/core/Application.java 2007-09-30 14:21:41 UTC (rev 10224)
+++ trunk/foray/foray-core/src/java/org/foray/core/Application.java 2007-09-30 16:15:45 UTC (rev 10225)
@@ -64,7 +64,7 @@
* @return The current version of the application.
*/
public static String getVersion() {
- return "0.3";
+ return "0.4-dev";
}
/**
Modified: trunk/foray/scripts/build-common.xml
===================================================================
--- trunk/foray/scripts/build-common.xml 2007-09-30 14:21:41 UTC (rev 10224)
+++ trunk/foray/scripts/build-common.xml 2007-09-30 16:15:45 UTC (rev 10225)
@@ -38,7 +38,7 @@
<property name="name.lowercase" value="foray"/>
<property name="contact.info"
value="The FOray project http://www.foray.org"/>
- <property name="version" value="0.3"/>
+ <property name="version" value="0.4-dev"/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="off"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-02 16:58:05
|
Revision: 10227
http://foray.svn.sourceforge.net/foray/?rev=10227&view=rev
Author: victormote
Date: 2007-10-02 09:58:08 -0700 (Tue, 02 Oct 2007)
Log Message:
-----------
Conform to axsl changes for getting the text of a bookmark title.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java 2007-09-30 16:28:43 UTC (rev 10226)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/BookmarkTitleArea.java 2007-10-02 16:58:08 UTC (rev 10227)
@@ -28,10 +28,7 @@
package org.foray.area;
-import org.foray.common.WKConstants;
-
import org.axsl.fo.fo.BookmarkTitle;
-import org.axsl.fo.fo.CharacterSequence;
import org.axsl.font.Font;
import java.awt.Color;
@@ -75,13 +72,7 @@
*/
public String getTitleText() {
final BookmarkTitle generatedBy = traitGeneratedBy();
- /* Allow for the possibility that the content is empty. */
- if (generatedBy.getChildCount() < 1) {
- return WKConstants.EMPTY_STRING;
- }
- final CharacterSequence charSequence = generatedBy.getChildAt(0);
- final char[] text = charSequence.getAreaTreeText(null);
- return new String(text);
+ return generatedBy.getText();
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2007-09-30 16:28:43 UTC (rev 10226)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2007-10-02 16:58:08 UTC (rev 10227)
@@ -28,6 +28,7 @@
package org.foray.fotree.fo.obj;
+import org.foray.common.WKConstants;
import org.foray.fotree.FObj;
import org.foray.fotree.FObjMixed;
import org.foray.fotree.Namespace;
@@ -237,4 +238,16 @@
return this.children.get(index);
}
+ /**
+ * {@inheritDoc}
+ */
+ public String getText() {
+ if (this.children.size() < 1) {
+ return WKConstants.EMPTY_STRING;
+ }
+ final CharacterSequence4a child = this.getChildAt(0);
+ final char[] text = child.getAreaTreeText(null);
+ return new String(text);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-02 22:53:52
|
Revision: 10231
http://foray.svn.sourceforge.net/foray/?rev=10231&view=rev
Author: victormote
Date: 2007-10-02 15:53:56 -0700 (Tue, 02 Oct 2007)
Log Message:
-----------
Clean up some javadoc problems.
Modified Paths:
--------------
trunk/foray/foray-app/src/java/org/foray/app/ant/RunTest.java
trunk/foray/foray-common/src/java/org/foray/common/Configuration.java
trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java
trunk/foray/foray-common/src/java/org/foray/common/RandomReaderURL.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/RunTest.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/ant/RunTest.java 2007-10-02 21:27:09 UTC (rev 10230)
+++ trunk/foray/foray-app/src/java/org/foray/app/ant/RunTest.java 2007-10-02 22:53:56 UTC (rev 10231)
@@ -235,7 +235,7 @@
meth = cla.getMethod("runTests", new Class[] {
String.class, String.class, String.class
});
- diff = (HashMap) meth.invoke(tc, new Object[] {
+ diff = (HashMap<?, ?>) meth.invoke(tc, new Object[] {
this.testsuite, dest, compDir
});
} catch (final Exception e) {
Modified: trunk/foray/foray-common/src/java/org/foray/common/Configuration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2007-10-02 21:27:09 UTC (rev 10230)
+++ trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2007-10-02 22:53:56 UTC (rev 10231)
@@ -168,7 +168,7 @@
protected List<?> getListValue(final String key) {
final Object obj = getValue(key);
if (obj instanceof List) {
- return (List) obj;
+ return (List<?>) obj;
}
return null;
}
@@ -358,7 +358,7 @@
this.logger.info(" value: " + value);
} else if (value instanceof List) {
final StringBuilder valueString = new StringBuilder();
- final List<?> list = (List) value;
+ final List<?> list = (List<?>) value;
valueString.append(" value: ");
for (int i = 0; i < list.size(); i++) {
final String item = (String) list.get(i);
Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2007-10-02 21:27:09 UTC (rev 10230)
+++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2007-10-02 22:53:56 UTC (rev 10231)
@@ -37,7 +37,7 @@
/**
* Implementation of RandomInput that uses a byte array.
*/
-class RandomReaderArray implements RandomInput {
+public class RandomReaderArray implements RandomInput {
/** The description of this array, used for user messages. */
private String description;
Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderURL.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderURL.java 2007-10-02 21:27:09 UTC (rev 10230)
+++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderURL.java 2007-10-02 22:53:56 UTC (rev 10231)
@@ -33,14 +33,15 @@
import java.net.URL;
/**
- * Implementation of RandomInput suitable for URLs that are not local files.
+ * Implementation of {@link RandomInput} suitable for URLs that are not local
+ * files.
* It is actually a thin wrapper around a {@link RandomReaderArray} instance.
* The idea here is to allow the encapsulated byte array to be released when it
* is not used, but to retain the URL in case it needs to be reopened.
- * If it does not need to ever be reopended, juse use {@link RandomReaderArray}
+ * If it does not need to ever be reopened, just use {@link RandomReaderArray}
* instead.
*/
-class RandomReaderURL implements RandomInput {
+public class RandomReaderURL implements RandomInput {
/** The encapsulated URL. */
private URL url;
Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-10-02 21:27:09 UTC (rev 10230)
+++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-10-02 22:53:56 UTC (rev 10231)
@@ -567,7 +567,7 @@
* @param millipoints The millipoint value to be converted to points.
* @return The converted value in points.
*/
- protected static float toPoints(final int millipoints) {
+ public static float toPoints(final int millipoints) {
return millipoints / (float) WKConstants.MILLIPOINTS_PER_POINT;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-02 23:01:14
|
Revision: 10232
http://foray.svn.sourceforge.net/foray/?rev=10232&view=rev
Author: victormote
Date: 2007-10-02 16:01:18 -0700 (Tue, 02 Oct 2007)
Log Message:
-----------
Clean up some javadoc problems.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRgb.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnSystemColor.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
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/WordList.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/util/TestNaturalLanguage.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -50,7 +50,7 @@
/**
* Handles interface of system (AWT) fonts to the client application.
*/
-final class SystemFont extends org.foray.font.FOrayFont {
+public final class SystemFont extends org.foray.font.FOrayFont {
/** The logical font families used by AWT Fonts. */
public static final String[] LOGICAL_FONT_FAMILIES = {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -35,7 +35,7 @@
/**
* The "ceiling" function in XSL-FO.
*/
-class FnCeiling extends Function {
+public class FnCeiling extends Function {
/** The operand to this function. */
private Expr operand1;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -35,7 +35,7 @@
/**
* The "floor" function in XSL-FO.
*/
-class FnFloor extends Function {
+public class FnFloor extends Function {
/** The operand to this function. */
private Expr operand1;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRgb.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRgb.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRgb.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -36,7 +36,7 @@
/**
* The "rgb" function in XSL-FO.
*/
-class FnRgb extends Function {
+public class FnRgb extends Function {
/** Constant indicating the number of channels in the RGB color space, that
* is, 3. */
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -35,7 +35,7 @@
/**
* The "round" function in XSL-FO.
*/
-class FnRound extends Function {
+public class FnRound extends Function {
/** The arguments to this function. */
private Expr operand1;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnSystemColor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnSystemColor.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnSystemColor.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -35,7 +35,7 @@
/**
* The "system-color" function in XSL-FO.
*/
-class FnSystemColor extends Function {
+public class FnSystemColor extends Function {
/** The name of this system color. */
private DtName colorName;
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -84,7 +84,6 @@
/**
* {@inheritDoc}
- * This implementation simply uses {@link #toString()}.
*/
public String getIDstring() {
return toString();
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -315,7 +315,7 @@
if (bold) {
weight = org.axsl.font.Font.Weight.BOLD;
}
- final List<?> gvtFonts = (List) aci.getAttribute(
+ final List<?> gvtFonts = (List<?>) aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES);
final int fsize = (int) size.floatValue();
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/WordList.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/WordList.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/WordList.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -244,7 +244,7 @@
* be removed.
* @return The cleaned-up word.
*/
- static String removeNonWordChars(final String token) {
+ public static String removeNonWordChars(final String token) {
String newString = token;
boolean anyChanges = true;
while (anyChanges) {
@@ -331,7 +331,7 @@
* @param input The input "word".
* @return True iff the word contains one or more non-word characters.
*/
- static boolean containsNonWord(final String input) {
+ public static boolean containsNonWord(final String input) {
for (int i = 0; i < input.length(); i++) {
final char c = input.charAt(i);
final int codePoint = input.codePointAt(i);
Modified: trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/util/TestNaturalLanguage.java
===================================================================
--- trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/util/TestNaturalLanguage.java 2007-10-02 22:53:56 UTC (rev 10231)
+++ trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/util/TestNaturalLanguage.java 2007-10-02 23:01:18 UTC (rev 10232)
@@ -44,7 +44,7 @@
/**
* Tests various Strings against the method
- * {@link NaturalLanguage#validateText(String)}.
+ * {@link NaturalLanguage#validateText(CharSequence)}.
* @throws IOException For errors creating the Hyphenation server.
*/
public void testValidateText() throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-03 17:36:24
|
Revision: 10233
http://foray.svn.sourceforge.net/foray/?rev=10233&view=rev
Author: victormote
Date: 2007-10-03 10:36:25 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
Conform to axsl changes providing page formatting information to downstream clients.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2007-10-02 23:01:18 UTC (rev 10232)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2007-10-03 17:36:25 UTC (rev 10233)
@@ -30,6 +30,7 @@
import org.axsl.area.PageArea;
import org.axsl.area.AreaTreeException;
+import org.axsl.common.PositiveIntegerFormatter;
import org.axsl.common.value.ForcePageCount;
import org.axsl.fo.FoTreeException;
import org.axsl.fo.fo.Marker;
@@ -448,4 +449,11 @@
return (PageSequence) this.getLinkage().getFONode();
}
+ /**
+ * {@inheritDoc}
+ */
+ public PositiveIntegerFormatter getPageNumberFormatter() {
+ return this.traitGeneratedBy().getPageNumberFormatter();
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java 2007-10-02 23:01:18 UTC (rev 10232)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java 2007-10-03 17:36:25 UTC (rev 10233)
@@ -28,37 +28,19 @@
package org.foray.fotree.fo.obj;
+import org.axsl.common.FormattedIntegerType;
+import org.axsl.common.PositiveIntegerFormatter;
+
/**
* This class uses the 'format', 'groupingSeparator', 'groupingSize',
* and 'letterValue' properties on fo:page-sequence to return a String
* corresponding to the supplied integer page number.
*/
-public class PageNumberGenerator {
+public class PageNumberGenerator implements PositiveIntegerFormatter {
- /**
- * Enumeration of valid format types.
- */
- public enum FormatType {
-
- /** Decimal format, that is 0, 1, 2, 3, etc. */
- DECIMAL,
-
- /** Lowercase alpha format, that is a, b, c, d, etc. */
- LOWERALPHA,
-
- /** Uppercase alpha format, that is A, B, C, D, etc. */
- UPPERALPHA,
-
- /** Lowercase roman format, that is i, ii, iii, iv, etc. */
- LOWERROMAN,
-
- /** Uppercase roman format, that is I, II, III, IV, etc. */
- UPPERROMAN;
-
- }
-
/** The format type that should be used by this formatter. */
- private FormatType formatType = PageNumberGenerator.FormatType.DECIMAL;
+ private FormattedIntegerType formatType =
+ FormattedIntegerType.DECIMAL_ARABIC;
/** The minimum amount of padding for decimal formats. */
private int minPadding = 0;
@@ -84,20 +66,21 @@
final int fmtLen = format.length();
if (fmtLen == 1) {
if (format.equals("1")) {
- this.formatType = PageNumberGenerator.FormatType.DECIMAL;
+ this.formatType = FormattedIntegerType.DECIMAL_ARABIC;
this.minPadding = 0;
} else if (format.equals("a")) {
- this.formatType = PageNumberGenerator.FormatType.LOWERALPHA;
+ this.formatType = FormattedIntegerType.LOWERCASE_LETTERS;
} else if (format.equals("A")) {
- this.formatType = PageNumberGenerator.FormatType.UPPERALPHA;
+ this.formatType = FormattedIntegerType.UPPERCASE_LETTERS;
} else if (format.equals("i")) {
- this.formatType = PageNumberGenerator.FormatType.LOWERROMAN;
+ this.formatType = FormattedIntegerType.LOWERCASE_ROMAN;
} else if (format.equals("I")) {
- this.formatType = PageNumberGenerator.FormatType.UPPERROMAN;
+ this.formatType = FormattedIntegerType.UPPERCASE_ROMAN;
} else {
- // token not handled
- //log.debug("'format' token not recognized; using '1'");
- this.formatType = PageNumberGenerator.FormatType.DECIMAL;
+ /* We don't know how to handle other types right now. Per the
+ * XSLT 1.0 spec, Section 7.7.1, such types should be handled
+ * as if they were decimal arabic. */
+ this.formatType = FormattedIntegerType.DECIMAL_ARABIC;
this.minPadding = 0;
}
} else {
@@ -107,7 +90,7 @@
for (int i = 0; i < fmtLen - 1; i++) {
if (format.charAt(i) != '0') {
//log.debug("'format' token not recognized; using '1'");
- this.formatType = PageNumberGenerator.FormatType.DECIMAL;
+ this.formatType = FormattedIntegerType.DECIMAL_ARABIC;
this.minPadding = 0;
} else {
this.minPadding = fmtLen - 1;
@@ -124,24 +107,24 @@
*/
public String makeFormattedPageNumber(final int number) {
String pn = null;
- if (this.formatType == PageNumberGenerator.FormatType.DECIMAL) {
+ if (this.formatType == FormattedIntegerType.DECIMAL_ARABIC) {
pn = Integer.toString(number);
if (this.minPadding >= pn.length()) {
final int nz = this.minPadding - pn.length() + 1;
pn = this.zeros[nz] + pn;
}
} else if ((this.formatType
- == PageNumberGenerator.FormatType.LOWERROMAN)
+ == FormattedIntegerType.LOWERCASE_ROMAN)
|| (this.formatType
- == PageNumberGenerator.FormatType.UPPERROMAN)) {
+ == FormattedIntegerType.UPPERCASE_ROMAN)) {
pn = makeRoman(number);
- if (this.formatType == PageNumberGenerator.FormatType.UPPERROMAN) {
+ if (this.formatType == FormattedIntegerType.UPPERCASE_ROMAN) {
pn = pn.toUpperCase();
}
} else {
// alphabetic
pn = makeAlpha(number);
- if (this.formatType == PageNumberGenerator.FormatType.UPPERALPHA) {
+ if (this.formatType == FormattedIntegerType.UPPERCASE_LETTERS) {
pn = pn.toUpperCase();
}
}
@@ -205,4 +188,11 @@
return alphaNumber.reverse().toString();
}
+ /**
+ * {@inheritDoc}
+ */
+ public FormattedIntegerType getType() {
+ return null;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2007-10-02 23:01:18 UTC (rev 10232)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2007-10-03 17:36:25 UTC (rev 10233)
@@ -32,6 +32,7 @@
import org.foray.fotree.Namespace;
import org.foray.fotree.PropertyList;
+import org.axsl.common.PositiveIntegerFormatter;
import org.axsl.fo.FoContext;
import org.axsl.fo.FoTreeException;
import org.axsl.fo.ProxyFactory;
@@ -419,4 +420,11 @@
return true;
}
+ /**
+ * {@inheritDoc}
+ */
+ public PositiveIntegerFormatter getPageNumberFormatter() {
+ return this.pageNumberGenerator;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-03 20:04:50
|
Revision: 10234
http://foray.svn.sourceforge.net/foray/?rev=10234&view=rev
Author: victormote
Date: 2007-10-03 13:04:54 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
Conform to axsl changes providing page number prefix and suffix information in both the FO Tree and Galley.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjMixed.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioPrefix.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioSuffix.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -28,11 +28,15 @@
package org.foray.area;
+import org.foray.common.WKConstants;
+
+import org.axsl.area.AreaTreeException;
import org.axsl.area.PageArea;
-import org.axsl.area.AreaTreeException;
import org.axsl.common.PositiveIntegerFormatter;
import org.axsl.common.value.ForcePageCount;
import org.axsl.fo.FoTreeException;
+import org.axsl.fo.fo.FolioPrefix;
+import org.axsl.fo.fo.FolioSuffix;
import org.axsl.fo.fo.Marker;
import org.axsl.fo.fo.PageMasterResolver;
import org.axsl.fo.fo.PageSequence;
@@ -456,4 +460,26 @@
return this.traitGeneratedBy().getPageNumberFormatter();
}
+ /**
+ * {@inheritDoc}
+ */
+ public String getPageNumberPrefix() {
+ final FolioPrefix prefix = this.traitGeneratedBy().getFolioPrefix();
+ if (prefix == null) {
+ return WKConstants.EMPTY_STRING;
+ }
+ return prefix.getContentAsText();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPageNumberSuffix() {
+ final FolioSuffix suffix = this.traitGeneratedBy().getFolioSuffix();
+ if (suffix == null) {
+ return WKConstants.EMPTY_STRING;
+ }
+ return suffix.getContentAsText();
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -118,6 +118,7 @@
import org.axsl.fo.FoContext;
import org.axsl.fo.FoInlineContext;
import org.axsl.fo.FoTreeException;
+import org.axsl.fo.fo.CharacterSequence;
import org.axsl.fo.fo.GraftingPoint;
import org.axsl.fo.fo.Marker;
import org.axsl.fo.fo.proforma.CommonFontExcludedPa;
@@ -4299,6 +4300,23 @@
}
/**
+ * Returns the descendant text nodes concatenated together.
+ * @return The descendant fo:character nodes, concatenated together.
+ */
+ public String getDescendantText() {
+ final StringBuilder builder = new StringBuilder();
+ final DescendantIterator iterator = this.getDescendantIterator();
+ while (iterator.hasNext()) {
+ final FObj fobj = iterator.next();
+ if (fobj instanceof CharacterSequence) {
+ final CharacterSequence text = (CharacterSequence) fobj;
+ builder.append(text.getAreaTreeText(null));
+ }
+ }
+ return builder.toString();
+ }
+
+ /**
* Returns the allowed-height-scale trait.
* @return The allowed-height-scale trait.
*/
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjMixed.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjMixed.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjMixed.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -125,13 +125,10 @@
/**
* {@inheritDoc}
*/
- @Override
public void addChild(final FObj child) throws FoTreeException {
- /*
- * Before adding the element child, see if there is any text in the
+ /* Before adding the child element, see if there is any text in the
* buffer. If so, create an FOText node before adding the element
- * just parsed.
- */
+ * just parsed. */
finalizeText(null);
/* Now add the element. */
this.addNonTextNode(child);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioPrefix.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioPrefix.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioPrefix.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -75,4 +75,11 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public String getContentAsText() {
+ return this.getDescendantText();
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioSuffix.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioSuffix.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/FolioSuffix.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -75,4 +75,11 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public String getContentAsText() {
+ return this.getDescendantText();
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2007-10-03 17:36:25 UTC (rev 10233)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2007-10-03 20:04:54 UTC (rev 10234)
@@ -427,4 +427,28 @@
return this.pageNumberGenerator;
}
+ /**
+ * {@inheritDoc}
+ */
+ public FolioPrefix getFolioPrefix() {
+ for (FObj child : this.getChildren()) {
+ if (child instanceof FolioPrefix) {
+ return (FolioPrefix) child;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public FolioSuffix getFolioSuffix() {
+ for (FObj child : this.getChildren()) {
+ if (child instanceof FolioSuffix) {
+ return (FolioSuffix) child;
+ }
+ }
+ return null;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-03 20:33:02
|
Revision: 10235
http://foray.svn.sourceforge.net/foray/?rev=10235&view=rev
Author: victormote
Date: 2007-10-03 13:33:05 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
Add logic to notify the PDF document about the page label changes.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java 2007-10-03 20:04:54 UTC (rev 10234)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberGenerator.java 2007-10-03 20:33:05 UTC (rev 10235)
@@ -192,7 +192,7 @@
* {@inheritDoc}
*/
public FormattedIntegerType getType() {
- return null;
+ return this.formatType;
}
}
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-10-03 20:04:54 UTC (rev 10234)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-10-03 20:33:05 UTC (rev 10235)
@@ -37,6 +37,8 @@
import org.foray.output.OutputConfig;
import org.foray.render.PrintRenderer;
+import org.axsl.common.FormattedIntegerType;
+import org.axsl.common.PositiveIntegerFormatter;
import org.axsl.common.value.LinkType;
import org.axsl.common.value.RuleStyle;
import org.axsl.font.Font;
@@ -50,6 +52,7 @@
import org.axsl.galley.Galley;
import org.axsl.galley.GraphicArea;
import org.axsl.galley.Page;
+import org.axsl.galley.PageCollection;
import org.axsl.galley.TextArea;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicLink;
@@ -64,6 +67,7 @@
import org.axsl.pdf.PdfOutlineItem;
import org.axsl.pdf.PdfOutlineParent;
import org.axsl.pdf.PdfPage;
+import org.axsl.pdf.PdfPageLabelStyle;
import org.axsl.pdf.PdfPathPaint;
import org.axsl.pdf.PdfVersion;
@@ -95,6 +99,12 @@
/** The current page being processed. */
private PdfPage currentPage;
+ /** The current area tree page being processed. */
+ private Page currentAreaTreePage;
+
+ /** The total number of pages processed so far. */
+ private int pageCount;
+
/**
* Constructor.
* @param logger The logger.
@@ -414,10 +424,13 @@
}
/**
- * Render page to PDF. {@inheritDoc}
+ * {@inheritDoc}
*/
public void render(final Page page) throws OutputException {
getLogger().debug("Rendering single page to PDF.");
+ this.pageCount ++;
+ checkPageLabels(page);
+ this.currentAreaTreePage = page;
final float w = page.getWidth();
final float h = page.getHeight();
this.currentPage = this.pdfDoc.createPdfPage(
@@ -436,6 +449,63 @@
}
/**
+ * If necessary, creates a new page label range entry in the PDF document.
+ * @param page The new area tree page being processed.
+ */
+ private void checkPageLabels(final Page page) {
+ final PageCollection currentCollection = page.getParent();
+ final PositiveIntegerFormatter currentFormatter =
+ currentCollection.getPageNumberFormatter();
+ final PdfPageLabelStyle labelStyle = PDFRenderer
+ .convertPageLabelStyle(currentFormatter.getType());
+
+ /* Handle special case of the first page. */
+ if (this.currentAreaTreePage == null) {
+ this.pdfDoc.addPageLabelRange(0, labelStyle,
+ currentCollection.getPageNumberPrefix(), page.getNumber());
+ return;
+ }
+
+ /* In all other cases, we are looking for changes from the last page. */
+ final PageCollection previousCollection =
+ this.currentAreaTreePage.getParent();
+ if (currentCollection == previousCollection) {
+ /* The pages are in the same PageCollection. No new page label range
+ * entry is needed. */
+ return;
+ }
+ final PositiveIntegerFormatter previousFormatter =
+ previousCollection.getPageNumberFormatter();
+ if (currentFormatter.getType() == previousFormatter.getType()
+ && currentCollection.getPageNumberPrefix()
+ .equals(previousCollection.getPageNumberPrefix())
+ && page.getNumber() == this.pageCount) {
+ return;
+ }
+ this.pdfDoc.addPageLabelRange(this.pageCount - 1, labelStyle,
+ currentCollection.getPageNumberPrefix(), page.getNumber());
+ }
+
+ /**
+ * Convert a standard generic page label numbering style into the
+ * PDF-specific style.
+ * @param fiType The standard generic page label numbering style to be
+ * converted.
+ * @return The equivalent PDF-specific page numbering style.
+ */
+ private static PdfPageLabelStyle convertPageLabelStyle(
+ final FormattedIntegerType fiType) {
+ switch(fiType) {
+ case DECIMAL_ARABIC: return PdfPageLabelStyle.DECIMAL_ARABIC;
+ case UPPERCASE_ROMAN: return PdfPageLabelStyle.UPPERCASE_ROMAN;
+ case LOWERCASE_ROMAN: return PdfPageLabelStyle.LOWERCASE_ROMAN;
+ case UPPERCASE_LETTERS: return PdfPageLabelStyle.UPPERCASE_LETTERS;
+ case LOWERCASE_LETTERS: return PdfPageLabelStyle.LOWERCASE_LETTERS;
+ default: return PdfPageLabelStyle.DECIMAL_ARABIC;
+ }
+ }
+
+ /**
* Using recursion, traverses the entire tree-fragment that is under this
* area, looking for Area instances that should trigger destinations in
* the output, and creating them.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-10-03 21:28:42
|
Revision: 10236
http://foray.svn.sourceforge.net/foray/?rev=10236&view=rev
Author: victormote
Date: 2007-10-03 14:28:44 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
Get page number label ranges written to the PDF.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumberTree.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFRoot.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabels.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2007-10-03 21:28:44 UTC (rev 10236)
@@ -22,7 +22,14 @@
<h3>Unreleased changes of interest to Users</h3>
<ul>
- <li>There are currently no such unreleased changes.</li>
+ <li>PDF output now contains page number range labels, which allows viewer
+applications to show the printed page number within the viewer application
+itself. For example, consider a 29-page document that starts with eight pages of
+front-matter that are numbered using Roman numerals (i - viii), followed by 21
+pages of content that is numbered using Arabic numerals (1 - 21). Before this
+change, Acrobat Reader would have displayed the fourth page as "4 / 29", and the
+ninth page as "9 / 29". It now shows the fourth page as "iv (4 of 29)", and the
+ninth page as "1 (9 of 29)".</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
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-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -770,7 +770,9 @@
public void addPageLabelRange(final int startingPageIndex,
final PdfPageLabelStyle labelStyle, final String labelPrefix,
final int startingPageNumber) {
- /* TODO: Implement this. */
+ final PDFPageLabel newPageLabel = new PDFPageLabel(this, labelStyle,
+ labelPrefix, startingPageNumber);
+ this.getRoot().addPageLabel(startingPageIndex, newPageLabel);
}
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumberTree.java 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumberTree.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -28,19 +28,19 @@
package org.foray.pdf.object;
-import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
/**
* A PDF Number Tree. The Number Tree is described in PDF Reference, Third
* Edition, Section 3.8.5.
- * @param <T> The type of value mapped in this name tree.
+ * @param <T> The type of value mapped in this number tree.
*/
public class PDFNumberTree<T extends PDFObject> extends PDFObject {
/* TODO: This currently handles a tree with only one level. */
/** This number tree's map. */
- private Map<Integer, T> nums = new HashMap<Integer, T>();
+ private Map<Integer, T> nums = new TreeMap<Integer, T>();
/**
* Constructor.
@@ -61,8 +61,7 @@
p.append("/Nums [" + EOL);
for (Map.Entry<Integer, T> entry : this.nums.entrySet()) {
final PDFObject pdfObject = entry.getValue();
- p.append("(" + entry.getKey() + ") " + pdfObject.pdfReference()
- + EOL);
+ p.append(entry.getKey() + " " + pdfObject.pdfReference() + EOL);
}
p.append("]" + EOL);
p.append(">>" + EOL);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -45,7 +45,7 @@
/**
* Constructor.
- * @param doc {@inheritDoc}
+ * @param doc The parent PDF document.
*/
public PDFOutlineParent(final PDFDocument doc) {
super(doc);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -62,10 +62,13 @@
* sequentially from this value.
*/
public PDFPageLabel(final PDFDocument doc, final PdfPageLabelStyle style,
- final PDFTextString labelPrefix, final int startingNumber) {
+ final String labelPrefix, final int startingNumber) {
super(doc);
this.style = style;
- this.labelPrefix = labelPrefix;
+ if (labelPrefix != null
+ && ! (labelPrefix.equals(""))) {
+ this.labelPrefix = new PDFTextString(doc, labelPrefix);
+ }
this.startingNumber = startingNumber;
doc.registerIndirectObject(this);
}
Deleted: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabels.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabels.java 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabels.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -1,69 +0,0 @@
-/*
- * 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: victormote $
- */
-
-package org.foray.pdf.object;
-
-/**
- * A PDF PageLabels Dictionary. See PDF Reference, 3rd Edition, Section 8.3.1.
- */
-public class PDFPageLabels extends PDFObject {
-
- /** The number tree containing the range values for the page labels in this
- * document. */
- private PDFNumberTree<PDFPageLabel> pageLabels;
-
- /**
- * Create a PDFPageLabels object.
- * @param doc The parent PDF document.
- */
- public PDFPageLabels(final PDFDocument doc) {
- super(doc);
- this.pageLabels = new PDFNumberTree<PDFPageLabel>(doc);
- doc.registerIndirectObject(this);
- }
-
- /**
- * Adds a range of pages to the page labels for this document.
- */
- public void addRange() {
-
- }
-
- /**
- * {@inheritDoc}
- */
- public String toPDF() {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("<< /Type /Catalog" + EOL);
- buffer.append("/PageLabels " + this.pageLabels.pdfReference());
- buffer.append(">>" + EOL + "endobj" + EOL);
- return buffer.toString();
- }
-
-}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFRoot.java 2007-10-03 20:33:05 UTC (rev 10235)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFRoot.java 2007-10-03 21:28:44 UTC (rev 10236)
@@ -36,6 +36,10 @@
/** The /Pages object that is root of the Pages hierarchy. */
private PDFPages rootPages;
+ /** The number tree containing the range values for the page labels in this
+ * document. */
+ private PDFNumberTree<PDFPageLabel> pageLabels;
+
/** The root outline object. */
private PDFOutline outline;
@@ -47,13 +51,12 @@
/**
* Create a Root (/Catalog) object.
- * @param doc {@inheritDoc}
+ * @param doc The parent PDF document.
*/
public PDFRoot(final PDFDocument doc) {
super(doc);
this.rootPages = new PDFPages(doc);
doc.registerIndirectObjectLast(this.rootPages);
-
}
/**
@@ -65,6 +68,31 @@
}
/**
+ * Returns the page labels in this document.
+ * @return The page labels in this document.
+ */
+ private PDFNumberTree<PDFPageLabel> getPageLabels() {
+ if (this.pageLabels == null) {
+ this.pageLabels = new PDFNumberTree<PDFPageLabel>(
+ this.getPDFDocument());
+ }
+ return this.pageLabels;
+ }
+
+ /**
+ * Adds a range of pages to the page labels for this document.
+ * @param pageIndex The 0-based page index of the first page in this range
+ * label.
+ * @param pageLabel The page label instance that handles formatting for page
+ * <code>pageIndex</code> until the next range label.
+ */
+ public void addPageLabel(final int pageIndex,
+ final PDFPageLabel pageLabel) {
+ final PDFNumberTree<PDFPageLabel> pageLabels = this.getPageLabels();
+ pageLabels.add(pageIndex, pageLabel);
+ }
+
+ /**
* Returns the destinations in this document.
* @return The destinations in this document.
*/
@@ -110,6 +138,9 @@
p.append("<<" + EOL);
p.append("/Type /Catalog" + EOL);
p.append("/Pages " + this.rootPages.pdfReference() + EOL);
+ if (this.pageLabels != null) {
+ p.append("/PageLabels " + this.pageLabels.pdfReference() + EOL);
+ }
if (this.outline != null) {
p.append(" /Outlines " + this.outline.pdfReference() + EOL);
p.append(" /PageMode /UseOutlines" + EOL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|