JAVA可以使用操作SVG文档的jar包


通过Batik,你可以在JAVA可以使用的地方操作SVG文档,您还可以在你的应用程序使用Batik模块来生成 , 处理和转码SVG图像。Batik很容易让基于Java的应用程序或小程序来处理SVG内容。
资源截图
代码片段和文件信息
/*

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You 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.

 */
import java.io.IOException;
import java.net.URL;

import javax.swing.Japplet; 

import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.util.xmlResourceDescriptor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * A applet demonstrating the JSVGCanvas.
 *
 * @version $Id$
 */
public class appletDemo extends Japplet {

    protected JSVGCanvas canvas;

    protected Document doc;

    protected Element svg;

    public void init() {
        // Create a new JSVGCanvas.
        canvas = new JSVGCanvas();
        getContentPane().add(canvas);

        try {
            // Parse the barChart.svg file into a Document.
            String parser = xmlResourceDescriptor.getxmlParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
            URL url = new URL(getCodebase() “barChart.svg“);
            doc = f.createDocument(url.toString());

            svg = doc.getDocumentElement();

            // Change the document viewBox.
            svg.setAttributeNS(null “viewBox“ “40 95 370 265“);

            // Make the text look nice.
            svg.setAttributeNS(null “text-rendering“ “geometricPrecision“);

            // Remove the xml-stylesheet PI.
            for (Node n = svg.getPreviousSibling();
                    n != null;
                    n = n.getPreviousSibling()) {
                if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
                    doc.removeChild(n);
                    break;
                }
            }

            // Remove the Batik sample mark ‘use‘ element.
            for (Node n = svg.getLastChild();
                    n != null;
                    n = n.getPreviousSibling()) {
                if (n.getNodeType() == Node.ELEMENT_NODE
                        && n.getLocalName().equals(“use“)) {
                    svg.removeChild(n);
                    break;
                }
            }
        } catch (Exception ex) {
        }
    }

    public void start() {
        // Display the document.
        canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
        canv

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-01-06 11:07  batik-1.7
     文件       62675  2008-01-01 10:20  batik-1.7CHANGES
     文件       11357  2006-11-16 12:27  batik-1.7LICENSE
     文件         684  2007-12-26 22:27  batik-1.7NOTICE
     文件        2862  2007-01-18 22:18  batik-1.7README
     目录           0  2008-01-06 11:04  batik-1.7docs
     目录           0  2008-01-06 11:04  batik-1.7docsdemo
     目录           0  2008-01-06 11:04  batik-1.7docsdev
     目录           0  2008-01-06 11:04  batik-1.7docsimages
     目录           0  2008-01-06 11:04  batik-1.7docsskin
     目录           0  2008-01-06 11:04  batik-1.7docsskincss
     目录           0  2008-01-06 11:04  batik-1.7docsskinimages
     目录           0  2008-01-06 11:04  batik-1.7docsskinscripts
     目录           0  2008-01-06 11:04  batik-1.7docsskin ranslations
     目录           0  2008-01-06 11:04  batik-1.7docs ools
     目录           0  2008-01-06 11:04  batik-1.7docs oolsimages
     目录           0  2008-01-06 11:04  batik-1.7docsusing
     目录           0  2008-01-06 11:04  batik-1.7docsusingimages
     目录           0  2008-01-06 11:04  batik-1.7docsusingscripting
     目录           0  2008-01-06 11:07  batik-1.7extensions
     文件       56270  2008-01-06 11:07  batik-1.7atik-rasterizer.jar
     文件       15216  2008-01-06 11:07  batik-1.7atik-slideshow.jar
     文件      553673  2008-01-06 11:07  batik-1.7atik-squiggle.jar
     文件       18152  2008-01-06 11:07  batik-1.7atik-svgpp.jar
     文件        6080  2008-01-06 11:07  batik-1.7atik-ttf2svg.jar
     文件        5238  2008-01-06 11:07  batik-1.7atik.jar
     文件        1871  2008-01-06 11:04  batik-1.7docs.htaccess
     文件          31  2008-01-06 11:04  batik-1.7docsroken-links.xml
     文件       25821  2008-01-06 11:04  batik-1.7docscontributors.html
     文件       11294  2008-01-06 11:04  batik-1.7docsdemo.html
     文件        1924  2008-01-06 11:04  batik-1.7docsdemoappletDemo$1.class
............此处省略693个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)