⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgexport.java

📁 完全基于java开发的svg矢量绘图工具
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Created on 8 déc. 2004 ============================================= GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 ============================================= GLIPS Graffiti Editor, a SVG Editor Copyright (C) 2003 Jordi SUC, Philippe Gil, SARL ITRIS  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  Contact : jordi.suc@itris.fr; philippe.gil@itris.fr  ============================================= */package fr.itris.glips.svgeditor.svgfile.export;import fr.itris.glips.svgeditor.*;import fr.itris.glips.svgeditor.canvas.*;import javax.swing.*;import java.awt.geom.*;import java.awt.image.*;import java.util.*;import java.awt.*;import java.awt.event.*;import java.io.*;import org.w3c.dom.svg.*;import org.apache.batik.gvt.*;import org.apache.batik.swing.*;import org.apache.batik.swing.gvt.*;import org.apache.batik.swing.svg.*;import fr.itris.glips.svgeditor.resources.*;import java.net.*;import com.lowagie.text.pdf.*;import com.lowagie.text.*;import com.sun.imageio.plugins.bmp.*;import com.sun.imageio.plugins.jpeg.*;import com.sun.imageio.plugins.png.*;import com.sun.media.imageioimpl.plugins.tiff.*;import javax.imageio.event.*;import javax.imageio.plugins.jpeg.*;import javax.imageio.plugins.bmp.*;import javax.imageio.stream.*;import javax.imageio.*;/** * the class that creates the static menu item export in the menu bar *  * @author Jordi SUC */public class SVGExport extends SVGModuleAdapter{        /**     * the ids of the module     */    final private String	idexport="Export";        /**     * the constant for the JPG format     */    public static final int JPG_FORMAT=0;        /**     * the constant for the PNG format     */    public static final int PNG_FORMAT=1;        /**     * the constant for the BMP format     */    public static final int BMP_FORMAT=2;        /**     * the constant for the GIF format     */    public static final int GIF_FORMAT=3;        /**     * the constant for the PDF format     */    public static final int PDF_FORMAT=4;        /**     * the constant for the TIFF format     */    public static final int TIFF_FORMAT=5;        /**     * the labels     */    private String labelexport="", erasefilemessage="", erasefiletitle="",     messageexporterror="", labelerror="", messageformaterrorexportjpg="",     messageformaterrorexportpng="", messageformaterrorexportbmp="", messageformaterrorexporttiff="",     messageformaterrorexportpdf="", labeljpg="", labelpng="", labelbmp="", labeltiff="", labelpdf="";        /**     * the editor     */    private SVGEditor editor;        /**     * the menu item that will be added to the menubar     */    private JMenu export;        /**     * the menu items used to choose the export file type     */    private JMenuItem jpgMenuItem, pngMenuItem, bmpMenuItem, tiffMenuItem, pdfMenuItem;        /**     * the dialog box used to choose the parameters for the jpg export     */    private JPGExportDialog jpgExportDialog=null;        /**     * the dialog box used to choose the parameters for the jpg export     */    private PNGExportDialog pngExportDialog=null;        /**     * the dialog box used to choose the parameters for the bmp export     */    private BMPExportDialog bmpExportDialog=null;        /**     * the dialog box used to choose the parameters for the jpg export     */    private TIFFExportDialog tiffExportDialog=null;        /**     * the dialog box used to choose the parameters for the pdf export     */    private PDFExportDialog pdfExportDialog=null;        /**     * the resource bundle     */    private ResourceBundle bundle=null;        /**     * the constructor of the class     * @param editor the editor     */    public SVGExport(SVGEditor editor){                this.editor=editor;                //gets the labels from the resources        bundle=SVGEditor.getBundle();                if(bundle!=null){                        try{                labelexport=bundle.getString("labelexport");                labeljpg=bundle.getString("labeljpgexportmi");                labelpng=bundle.getString("labelpngexportmi");                labelbmp=bundle.getString("labelbmpexportmi");                labeltiff=bundle.getString("labeltiffexportmi");                labelpdf=bundle.getString("labelpdfexportmi");                erasefilemessage=bundle.getString("erasefilemessage");                erasefiletitle=bundle.getString("erasefiletitle");                messageexporterror=bundle.getString("messageexporterror");                labelerror=bundle.getString("labelerror");                messageformaterrorexportjpg=bundle.getString("messageformaterrorexportjpg");                messageformaterrorexportpng=bundle.getString("messageformaterrorexportpng");                messageformaterrorexportbmp=bundle.getString("messageformaterrorexportbmp");                messageformaterrorexporttiff=bundle.getString("messageformaterrorexporttiff");                messageformaterrorexportpdf=bundle.getString("messageformaterrorexportpdf");            }catch (Exception ex){}        }                //a listener that listens to the changes of the SVGFrames        final ActionListener svgframeListener=new ActionListener(){                        public void actionPerformed(ActionEvent e) {                                final SVGFrame frame=getSVGEditor().getFrameManager().getCurrentFrame();                                if(frame!=null){                                        //enables the menuitem                    export.setEnabled(true);                                    }else{                                        //disables the menuitem                    export.setEnabled(false);                }            }	        };                //adds the SVGFrame change listener        editor.getFrameManager().addSVGFrameChangedListener(svgframeListener);                //getting the icons        ImageIcon exportIcon=SVGResource.getIcon("Export", false),        dexportIcon=SVGResource.getIcon("Export", true);                //creating the menu items        jpgMenuItem=new JMenuItem(labeljpg);        pngMenuItem=new JMenuItem(labelpng);        bmpMenuItem=new JMenuItem(labelbmp);        tiffMenuItem=new JMenuItem(labeltiff);        pdfMenuItem=new JMenuItem(labelpdf);                //handling the menu        export=new JMenu(labelexport);                export.add(jpgMenuItem);        export.add(pngMenuItem);        export.add(bmpMenuItem);        export.add(tiffMenuItem);        export.add(pdfMenuItem);                export.setIcon(exportIcon);        export.setDisabledIcon(dexportIcon);                //disabled by default since no SVGFrame has been loaded        export.setEnabled(false);                //creating and adding a  listener to the menu items        ActionListener listener=new ActionListener() {                        public void actionPerformed(ActionEvent evt) {                                SVGFrame frame=getSVGEditor().getFrameManager().getCurrentFrame();                                if(frame!=null){                                        if(evt.getSource().equals(jpgMenuItem)) {                                                exportAction(frame, JPG_FORMAT);                                            }else if(evt.getSource().equals(pngMenuItem)) {                                                exportAction(frame, PNG_FORMAT);                                            }else if(evt.getSource().equals(bmpMenuItem)) {                                                exportAction(frame, BMP_FORMAT);                                            }else if(evt.getSource().equals(tiffMenuItem)) {                                                exportAction(frame, TIFF_FORMAT);                                            }else if(evt.getSource().equals(pdfMenuItem)) {                                                exportAction(frame, PDF_FORMAT);                    }                }            }         };                jpgMenuItem.addActionListener(listener);        pngMenuItem.addActionListener(listener);        bmpMenuItem.addActionListener(listener);        tiffMenuItem.addActionListener(listener);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -