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

📄 svgabout.java

📁 完全基于java开发的svg矢量绘图工具
💻 JAVA
字号:
/* * Created on 18 juil. 2004 *  =============================================                   GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 =============================================GLIPS Graffiti Editor, a SVG EditorCopyright (C) 2003 Jordi SUC, Philippe Gil, SARL ITRISThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USAContact : jordi.suc@itris.fr; philippe.gil@itris.fr ============================================= */package fr.itris.glips.svgeditor;import javax.swing.*;import javax.swing.border.*;import java .awt.*;import java.awt.event.*;import java.util.*;import fr.itris.glips.svgeditor.menutool.*;import fr.itris.glips.svgeditor.resources.*;/** * the class used to display the "about" dialog * @author Jordi SUC * */public class SVGAbout extends SVGModuleAdapter{		/**	 * the id	 */	private String idAbout="About";	/**	 * the labels	 */	private String labelAbout="";		/**	 * the menu item	 */	private final JMenuItem about=new JMenuItem();		/**	 * the resource bundle	 */	private ResourceBundle bundle=null;		/**	 * the editor	 */	private SVGEditor editor;		/**	 * the listener to the about menu items	 */	private ActionListener aboutListener=null;	/**	 * the constructor of the class	 * @param editor the editor	 */	public SVGAbout(SVGEditor editor){		this.editor=editor;				//the resource bundle        bundle=SVGEditor.getBundle();				if(bundle!=null){		    		    try{		        labelAbout=bundle.getString("labelabout");		    }catch (Exception ex){}		}				//getting the icons		ImageIcon aboutIcon=SVGResource.getIcon("About", false),						daboutIcon=SVGResource.getIcon("About", true);				//the menuitem		about.setText(labelAbout);		about.setIcon(aboutIcon);		about.setDisabledIcon(daboutIcon);				//the dialog		final AboutDialog aboutDialog=new AboutDialog();				//creating the listener to the menu item		aboutListener=new ActionListener(){		    			public void actionPerformed(ActionEvent evt) {			    				//sets the location of the dialog box				int 	x=(int)(SVGEditor.getParent().getLocationOnScreen().getX()+SVGEditor.getParent().getWidth()/2-aboutDialog.getSize().getWidth()/2), 						y=(int)(SVGEditor.getParent().getLocationOnScreen().getY()+SVGEditor.getParent().getHeight()/2-aboutDialog.getSize().getHeight()/2);								aboutDialog.setLocation(x,y);			    aboutDialog.setVisible(true);			}		};				about.addActionListener(aboutListener);	}	@Override	public Hashtable<String, JMenuItem> getMenuItems(){				Hashtable<String, JMenuItem> menuItems=new Hashtable<String, JMenuItem>();		menuItems.put(idAbout, about);				return menuItems;	}		@Override	public Collection<SVGPopupItem> getPopupItems(){				LinkedList<SVGPopupItem> popupItems=new LinkedList<SVGPopupItem>();				//creating the about popup item		SVGPopupItem item=new SVGPopupItem(getSVGEditor(), idAbout, labelAbout, "About"){					@Override			public JMenuItem getPopupItem(LinkedList nodes) {								//adds the action listeners				menuItem.addActionListener(aboutListener);								return super.getPopupItem(nodes);			}		};				popupItems.add(item);		return popupItems;	}		/**	 * @return the editor	 */	public SVGEditor getSVGEditor(){		return editor;	}		/**	 * the dialog that will be shown	 * @author Jordi SUC	 */	protected class AboutDialog extends JDialog{	    		/**		 * the dialog frame		 */		private final JDialog dialog=this;	    		/**		 * the constructor of the class		 */	    protected AboutDialog(){	        	        setTitle(labelAbout);	        	        JPanel panel=new JPanel();	        panel.setLayout(new BorderLayout());	        	        final ImageIcon image=SVGResource.getIcon("Splash", false);	        if(image!=null){	            //creating the panel that will contain the image	            JPanel imagePanel=new JPanel(){	            	@Override                    protected void paintComponent(Graphics evt) {                        super.paintComponent(evt);                        image.paintIcon(this, evt, 0, 0);                    }	            };	            	            imagePanel.setLayout(null);	            imagePanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED));	            	            imagePanel.setPreferredSize(new Dimension(image.getIconWidth(), image.getIconHeight()));	            panel.add(imagePanel, BorderLayout.CENTER);	        }	        	        //creating the panel that will contain the button	        JPanel buttonPanel=new JPanel();	        buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));	        panel.add(buttonPanel, BorderLayout.SOUTH);	        	        //creating the ok button	        String okLabel="";	        			//gets the labels from the resources						if(bundle!=null){			    		        try{		            okLabel=bundle.getString("labelok");		        }catch (Exception ex){}			}	        	        final JButton okButton=new JButton(okLabel);	        buttonPanel.add(okButton);	        	        //adding the listeners	        ActionListener actionListener=new ActionListener(){	            	            public void actionPerformed(ActionEvent arg0) {	                	                dialog.setVisible(false);	            } 	        };	        	        okButton.addActionListener(actionListener);	        	        final AWTEventListener keyListener=new AWTEventListener(){	            	            public void eventDispatched(AWTEvent e) {	                	                if(e instanceof KeyEvent && dialog.isVisible()){	                    	                    KeyEvent kev=(KeyEvent)e;		                if(kev.getID()==KeyEvent.KEY_PRESSED && kev.getKeyCode()==KeyEvent.VK_ENTER){		                    		                    okButton.doClick();		                }	                }	            }	        };	        	        Toolkit.getDefaultToolkit().addAWTEventListener(keyListener, AWTEvent.KEY_EVENT_MASK);	        	        getContentPane().add(panel);	        pack();	    }	}}

⌨️ 快捷键说明

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