[FOray-commit] SF.net SVN: foray:[11817] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-01-18 01:10:31
|
Revision: 11817
http://sourceforge.net/p/foray/code/11817
Author: victormote
Date: 2021-01-18 01:10:29 +0000 (Mon, 18 Jan 2021)
Log Message:
-----------
Upgrade JEuclid to 3.1.14.
Modified Paths:
--------------
trunk/foray/foray-graphic/build.gradle
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/master/build.gradle
Modified: trunk/foray/foray-graphic/build.gradle
===================================================================
--- trunk/foray/foray-graphic/build.gradle 2021-01-17 23:01:33 UTC (rev 11816)
+++ trunk/foray/foray-graphic/build.gradle 2021-01-18 01:10:29 UTC (rev 11817)
@@ -17,7 +17,8 @@
api group: 'org.apache.xmlgraphics', name: 'batik-awt-util', version: batikVersion
api group: 'org.apache.xmlgraphics', name: 'batik-ext', version: batikVersion
api group: 'org.apache.xmlgraphics', name: 'batik-svggen', version: batikVersion
- api group: 'net.sourceforge.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
+// api group: 'net.sourceforge.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
+ api group: 'de.rototor.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
api group: 'org.axsl', name: 'axsl-pdf', version: axslVersion
api project(':foray-common')
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2021-01-17 23:01:33 UTC (rev 11816)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2021-01-18 01:10:29 UTC (rev 11817)
@@ -54,8 +54,6 @@
import org.axsl.graphic.output.GraphicOutput;
import org.apache.batik.anim.dom.SVGDOMImplementation;
-import org.apache.batik.svggen.SVGGeneratorContext;
-import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
@@ -68,7 +66,6 @@
import org.w3c.dom.mathml.MathMLDocument;
import org.w3c.dom.svg.SVGDocument;
-import java.awt.Dimension;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -83,8 +80,10 @@
import javax.xml.parsers.ParserConfigurationException;
-import net.sourceforge.jeuclid.DOMBuilder;
-import net.sourceforge.jeuclid.MathBase;
+import net.sourceforge.jeuclid.LayoutContext;
+import net.sourceforge.jeuclid.context.LayoutContextImpl;
+import net.sourceforge.jeuclid.converter.Converter;
+import net.sourceforge.jeuclid.converter.ConverterPlugin.DocumentWithDimension;
/**
* create Graphic objects (with a configuration file - not yet implemented).
@@ -432,104 +431,10 @@
+ "MathML document, but was: " + rootElementName);
}
- /*
- * The pro-forma changes for upgrading to JEuclid 3.1.9 are as follows:
- * 1. Change the ext.jeuclidVersion variable in the master build.gradle to '3.1.9'.
- * 2. Uncomment the following section of code.
- * 3. Remove the remainder of the code in this method.
- * 4. Remove the method below this one, having the signature: SVGGraphics2D createSVGGenerator(MathBase).
- *
- * This looks like it /ought/ to work, and in fact compiles cleanly. However, at runtime, when testing MathML
- * documents, it results in the following:
- *
- * Exception in thread "main" java.lang.AbstractMethodError:
- * net.sourceforge.jeuclid.elements.presentation.token.Mo.getTextContent()Ljava/lang/String;
- * at net.sourceforge.jeuclid.elements.support.text.TextContent.getText(TextContent.java:44)
- * at net.sourceforge.jeuclid.elements.AbstractJEuclidElement.getText(AbstractJEuclidElement.java:413)
- * ...
- * at net.sourceforge.jeuclid.converter.BatikConverter.convert(BatikConverter.java:93)
- * at net.sourceforge.jeuclid.converter.Converter.convert(Converter.java:214)
- * at org.foray.graphic.GraphicServer4a.domToSvgDom(GraphicServer4a.java:436)
- * ...
- *
- * This is an unusual exception, basically meaning that something unexpected happened between compile time and
- * runtime. It may also be possible that there is some incompatibility between Java versions of code included
- * in the JEuclid distribution, and/or the FOray dependencies.
- *
- * In any case, this appears to be unsolvable without building JEuclid ourselves, which does not currently
- * (January 13, 2021) appear to be worth the effort.
- */
-
-
- /* Pro-forma JEuclid 3.1.9 code. See above. */
- /*
final Converter converter = Converter.getInstance();
final LayoutContext layoutContext = LayoutContextImpl.getDefaultLayoutContext();
final DocumentWithDimension dwd = converter.convert(dom, Converter.TYPE_SVG, layoutContext);
return (SVGDocument) dwd.getDocument();
- */
-
-
- final MathBase mathBase = new MathBase(MathBase.getDefaultParameters());
- new DOMBuilder(dom, mathBase);
- final SVGGraphics2D svgGenerator = this.createSVGGenerator(mathBase);
- mathBase.paint(svgGenerator);
-
- /* The following line is what /should/ work. However, there appears to
- * be some disconnect in Batik between the Document and the root
- * Element. The root Element recognizes the Document as its Document,
- * but the Document does not see the root Element as its root Element
- * ... */
-// final Document svgDocument = svgGenerator.getDOMFactory();
-
- final Element svgRoot = svgGenerator.getRoot();
-
- /* The variable svgDocument below is the same object as the one
- * commented out above ... */
- final Document svgDocument = svgRoot.getOwnerDocument();
- if (svgDocument == null) {
- throw new GraphicException("Error converting MathML to SVG: "
- + "Document is null.");
- }
-
- /* ... however, the root element below is /NOT/ the same as the svgRoot
- * variable above ... */
- final Element svgRoot2 = svgDocument.getDocumentElement();
-
- /* ... so we need to get the Document and the root element hooked up. */
- svgDocument.removeChild(svgRoot2);
- svgDocument.appendChild(svgRoot);
-
- 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.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;
- }
-
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java 2021-01-17 23:01:33 UTC (rev 11816)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java 2021-01-18 01:10:29 UTC (rev 11817)
@@ -101,7 +101,8 @@
*/
public static InputStream getMathMLDtdAsInputStream(final String fileName) {
/* We expect to find the MathML DTD in the JEuclid jar file at "mathml.2.0/mathml2.dtd". */
- final InputStream theStream = MathMlUtil.class.getResourceAsStream("/mathml.2.0/" + fileName);
+ final InputStream theStream =
+ MathMlUtil.class.getResourceAsStream("/net/sourceforge/jeuclid/mathml.2.0/" + fileName);
return theStream;
}
Modified: trunk/foray/master/build.gradle
===================================================================
--- trunk/foray/master/build.gradle 2021-01-17 23:01:33 UTC (rev 11816)
+++ trunk/foray/master/build.gradle 2021-01-18 01:10:29 UTC (rev 11817)
@@ -43,7 +43,7 @@
ext.servletApiVersion = '3.1.0' // Latest is 4.0.1 as of 2021-01-12. See Note 6.
ext.xmlgraphicsCommonsVersion = '2.4' // Latest is 2.4 as of 2021-01-12.
ext.batikVersion = '1.13' // Latest is 1.13 as of 2021-01-12.
- ext.jeuclidVersion = '3.0.3' // Latest is 3.1.9 as of 2021-01-12. See Note 7.
+ ext.jeuclidVersion = '3.1.14' // Latest is 3.1.14 as of 2021-01-12. See Note 7.
ext.icu4jVersion = '68.2' // Latest is 68.2 as of 2021-01-12.
ext.junitVersion = '4.13.1' // Latest is 5.7.0 as of 2021-01-12. See Note 8.
@@ -76,14 +76,9 @@
* to build with Java 1.7.
* We have therefore stayed with the highest version of 3.x, which is 3.1.0.
*
- * 7. JEuclid 3.1.9 will require handling some API changes.
- * Making those API changes results in runtime problems, which are documented, along with the pro-forma necessary
- * code changes, here:
- * project: foray-graphic
- * class: org.foray.graphic.GraphicServer4a
- * method: org.w3c.dom.svg.SVGDocument domToSvgDom(org.w3c.dom.Document)
- * JEuclid does not appear to be supported any longer, and I don't see any other MathML solutions with the right
- * licensing. Therefore we will leave this dependency at 3.0.3 for now.
+ * 7. JEuclid has moved from group net.sourceforge.jeuclid to de.rototor.jeuclid, but continues to use the name
+ * "jeuclid-core" and the same general release numbering sequence.
+ * The latest version for group net.sourceforge.jeuclid as of 2021-01-12 is 3.1.9 per www.mvnrepository.com.
*
* 8. JUnit is compiled with Java 8 (major version 52) starting with release 5.0.0.
* We have therefore stayed with the highest version supporting Java 7, which is 4.13.1.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|