Package net.sourceforge.jeuclid

Examples of net.sourceforge.jeuclid.MathBase


                    } catch (IOException ioe) {
                        log.error("Error while resetting ImageInputStream", ioe);
                    }
                    return null;
                }
                final MathBase base = new MathBase(
                                  mathBuilder.getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);
               
                ImageInfo info = new ImageInfo(uri, "text/mathml");
                final ImageSize size = new ImageSize();
                size.setSizeInMillipoints(
                        Math.round(base.getWidth() * 1000),
                        Math.round(base.getHeight() * 1000));
                //Set the resolution to that of the FOUserAgent
                size.setResolution(context.getSourceResolution());
                size.calcPixelsFromSize();
                info.setSize(size);

                Graphics2DImagePainter painter = new Graphics2DImagePainter() {

                    public Dimension getImageSize() {
                        return size.getDimensionMpt();
                    }

                    public void paint(Graphics2D g2d, Rectangle2D area) {
                        base.paint(g2d);
                    }
                   
                };
               
                //The whole image had to be loaded for this, so keep it
View Full Code Here


                int fontstyle = 0;
                //int inlinefontstyle = 0;
                int displayfontsize = 12;
                int inlinefontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                svgDoc = createSVG(base);

                width = base.getWidth();
                height = base.getHeight();

                doc = svgDoc;
            }
        } catch (Throwable t) {
            getLogger().error("Could not convert MathML to SVG", t);
View Full Code Here

                int fontstyle = 0;
                int inlinefontstyle = 0;
                int inlinefontsize = 12;
                int displayfontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                info.data = MathMLElement.createSVG(base);

                info.width = base.getWidth();
                info.height = base.getHeight();

                info.mimeType = "image/svg+xml";
                info.str = "http://www.w3.org/2000/svg";

                return info;
View Full Code Here

                int fontstyle = 0;
                //int inlinefontstyle = 0;
                int displayfontsize = 12;
                int inlinefontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                svgDoc = createSVG(base);

                width = base.getWidth();
                height = base.getHeight();

                doc = svgDoc;
            }
        } catch (Throwable t) {
            getLogger().error("Could not convert MathML to SVG", t);
View Full Code Here

                int fontstyle = 0;
                int inlinefontstyle = 0;
                int inlinefontsize = 12;
                int displayfontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                info.data = MathMLElement.createSVG(base);

                info.width = base.getWidth();
                info.height = base.getHeight();

                info.mimeType = "image/svg+xml";
                info.str = "http://www.w3.org/2000/svg";

                return info;
View Full Code Here

                int fontstyle = 0;
                //int inlinefontstyle = 0;
                int displayfontsize = 12;
                int inlinefontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                svgDoc = createSVG(base);

                width = base.getWidth();
                height = base.getHeight();

                doc = svgDoc;
            }
        } catch (Throwable t) {
            getLogger().error("Could not convert MathML to SVG", t);
View Full Code Here

                int fontstyle = 0;
                int inlinefontstyle = 0;
                int inlinefontsize = 12;
                int displayfontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                info.data = MathMLElement.createSVG(base);

                info.width = base.getWidth();
                info.height = base.getHeight();

                info.mimeType = "image/svg+xml";
                info.str = "http://www.w3.org/2000/svg";

                return info;
View Full Code Here

                int fontstyle = 0;
                //int inlinefontstyle = 0;
                int displayfontsize = 12;
                int inlinefontsize = 12;

                MathBase base = new MathBase(
                                  (new DOMMathBuilder(doc)).getMathRootElement(),
                                  fontname, fontstyle, inlinefontsize,
                                  displayfontsize);

                base.setDebug(false);

                svgDoc = createSVG(base);

                width = base.getWidth();
                height = base.getHeight();

                doc = svgDoc;
            }
        } catch (Throwable t) {
            getLogger().error("Could not convert MathML to SVG", t);
View Full Code Here

        if (! MathMLUtil.MATHML_ROOT_ELEMENT_NAME.equals(rootElementName)) {
            throw new GraphicException("Expected root element <math> for "
                    + "MathML document, but was: " + rootElementName);
        }

        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
View Full Code Here

      for (int i = 0; i < includedFiles.length; i++)
      {
        String filename = includedFiles[i];
        File absoluteFile = new File(filesetBaseDir, filename);
        File destinationFile = new File(toDir, m.mapFileName(filename)[0]);
        MathBase base = null;
                                float baseline = 0;
        SVGGraphics2D canvas = null;

        Document inputDocument;
        try {
          inputDocument = MathMLParserSupport.parseFile(absoluteFile);
          Map<ParameterKey, String> params = MathBase.getDefaultParameters();
          params.put(ParameterKey.FontSize, ((Integer) m_size).toString());
          params.put(ParameterKey.OutFileType, "image/svg+xml");
          // Font f = new Font(m_font, Font.PLAIN, m_size);
          base = MathMLParserSupport.createMathBaseFromDocument(inputDocument, params);

          DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
          Document outputDocument = domImpl.createDocument(null, "svg", null);
          canvas = new SVGGraphics2D(outputDocument);

                                        baseline = base.getDescender(canvas);
          float width = base.getWidth(canvas);
          float height = base.getHeight(canvas);
          Dimension d = new Dimension();
          d.setSize(width, height);
          canvas.setSVGCanvasSize(d);

          base.paint(canvas);

        } catch (SAXException e) {
          log("Error reading file " + absoluteFile.getName(), Project.MSG_WARN);
        } catch (IOException e) {
          log("Error reading file " + absoluteFile.getName(), Project.MSG_WARN);
View Full Code Here

TOP

Related Classes of net.sourceforge.jeuclid.MathBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.