Package org.axsl.graphic

Examples of org.axsl.graphic.GraphicException


        final File file = new File(getGraphic().getUrl().getFile());
        PsInput psInput = null;
        try {
            psInput = this.getPDFDocument().getPsServer().makePsInput(file);
        } catch (final IOException e) {
            throw new GraphicException("Cannot open EPS file.");
        }
        final PsServer psServer = this.getPDFDocument().getPsServer();
        PsSystemDict systemDict = null;
        try {
            systemDict = psServer.getPdfSystemDict();
            final PsInterpreter interpreter = psServer.makeInterpreter(psInput, systemDict);
            interpreter.process();
        } catch (final PsInterpreterException e1) {
            getLogger().error(e1.getMessage());
            throw new GraphicException("Cannot parse EPS file.");
        } catch (final PsException e1) {
            getLogger().error(e1.getMessage());
            throw new GraphicException("Cannot parse EPS file.");
        }
        final byte[] pdfBytes = systemDict.getOutput();
        return pdfBytes;
    }
View Full Code Here


        SVGDocument doc = null;
        doc = this.svg.getSvgDocument();
        final PDFGraphics2D graphics = getPDFContent4SVG(fontConsumer, doc,
                strokeText, outputContext, output);
        if (graphics == null) {
            throw new GraphicException("Unable to convert to PDF: "
                    + this.svg.getUrl().toExternalForm());
        }
        graphics.dispose();
        if (graphics.ioErrorFound()) {
            throw new GraphicException("I/O error(s) while converting to PDF: "
                    + this.svg.getUrl().toExternalForm());
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public byte[] getRawSamples() throws GraphicException {
        /* TODO: Add support for this feature. */
        throw new GraphicException("Unsupported feature getRawSamples() in "
                + this.getClass().getName() + "for: "
                + this.getUrl().toExternalForm());
    }
View Full Code Here

        try {
            final BufferedImage bi = new BufferedImage(1, 1,
                    BufferedImage.TYPE_INT_ARGB);
            this.fmg = bi.createGraphics();
        } catch (final LinkageError e) {
            throw new GraphicException("Unable to create graphical "
                    + "environment required to process SVG. Aborting.");
        }
    }
View Full Code Here

     * @throws GraphicException If {@code graphic} is not an instanceof {@link Graphic4a}.
     */
    public Graphic4a getGraphic4a(final Graphic graphic)
            throws GraphicException {
        if (! (graphic instanceof Graphic4a)) {
            throw new GraphicException("Unknown Graphic implementation.");
        }
        return (Graphic4a) graphic;
    }
View Full Code Here

                this.getPDFDocument(), efsName);
        final byte[] efsContent = this.graphic.getContent();
        try {
            embeddedFile.setData(efsContent);
        } catch (final PdfException e) {
            throw new GraphicException(e);
        }
        this.fileSpec = new PDFFileSpec(doc, embeddedFile);
    }
View Full Code Here

        List<URL> urlList;
        // An exception was thrown in buildURLList if urlList is null.
        try {
            urlList = URLUtil.buildURLList(baseURLs, href);
        } catch (final MalformedURLException e) {
            throw new GraphicException(e.getMessage());
        }
        // See if any of the possibilities are in our cache
        for (int i = 0; i < urlList.size(); i++) {
            absoluteURL = urlList.get(i);
            final Graphic4a imageObject = this.urlMap.get(href);
            if (imageObject != null) {
                return imageObject;
            }
        }

        // Try each one until one successfully opens
        for (int i = 0; i < urlList.size(); i++) {
            absoluteURL = urlList.get(i);
            try {
                final InputStream inputStream = absoluteURL.openStream();
                if (inputStream != null) {
                    imgIS = new BufferedInputStream(inputStream);
                }
            } catch (final IOException e1) {
                /*
                 * Ignore this. We'll throw an Exception at the end if none
                 * of these work.
                 */
            }
            if (imgIS != null) {
                break;
            }
        }
        if (imgIS == null) {
            throw new GraphicException("Cannot open URL: " + href);
        }

        final Graphic4a graphic = createGraphic(absoluteURL, imgIS);

        if (graphic == null) {
            throw new GraphicException("No Graphic Factory: "
                    + absoluteURL.toString());
        }

        if (cachingThisGraphic) {
            final String key = absoluteURL.getFile();
View Full Code Here

        for (int i = 0; i < factoryList.size(); i++) {
            final GraphicFactory factory = factoryList.get(i);
            try {
                graphic = factory.makeGraphic(absoluteURL, imgIS);
            } catch (final IOException e) {
                throw new GraphicException("Error parsing Graphic: "
                        + e.getMessage());
            }
            if (graphic != null) {
                return graphic;
            }
View Full Code Here

    public MathMLDocument makeMathDocument() throws GraphicException {
        MathMLDocument document;
        try {
            document = MathMLDocument4a.makeDocument(null, null, null);
        } catch (final ParserConfigurationException e) {
            throw new GraphicException(e);
        }
        return document;
    }
View Full Code Here

    public SVGDocument domToSvgDom(final Document dom)
            throws GraphicException {
        /* Do some basic validation of the DOM document. */
        final Element rootElement = dom.getDocumentElement();
        if (! MathMLUtil.MATHML_NAMESPACE.equals(rootElement.getNamespaceURI())) {
            throw new GraphicException("Document is not in the MathML "
                    + "namespace");
        }
        final String rootElementName = rootElement.getLocalName();
        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
         * ... */
//        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;
    }
View Full Code Here

TOP

Related Classes of org.axsl.graphic.GraphicException

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.