📄 svgeditor.java~1~
字号:
* @return the map containing the bounds of each widget in the main frame */ protected Map<String, Rectangle> getWidgetBoundsMap(){ Map<String, Rectangle> map=new Hashtable<String, Rectangle>(); Document doc=SVGResource.getXMLDocument("config.xml"); if(doc!=null){ Element root=doc.getDocumentElement(); if(root!=null){ //getting the node containing the nodes giving the bounds of the widgets in the main frame Node cur=null, bounds=null; for(cur=root.getFirstChild(); cur!=null; cur=cur.getNextSibling()){ if(cur instanceof Element && cur.getNodeName().equals("bounds")){ bounds=cur; break; } } if(bounds!=null){ //filling the map with the bounds Rectangle rectBounds=null; int x=0, y=0, width=0, height=0; String name, strX, strY, strW, strH; Element el=null; for(cur=bounds.getFirstChild(); cur!=null; cur=cur.getNextSibling()){ if(cur instanceof Element && cur.getNodeName().equals("widget")){ el=(Element)cur; //the name of the widget name=el.getAttribute("name"); //getting each value of the bounds strX=el.getAttribute("x"); strY=el.getAttribute("y"); strW=el.getAttribute("width"); strH=el.getAttribute("height"); x=0; y=0; width=0; height=0; try{ x=Integer.parseInt(strX); y=Integer.parseInt(strY); width=Integer.parseInt(strW); height=Integer.parseInt(strH); }catch (Exception ex){} //creating the rectangle rectBounds=new Rectangle(x, y, width, height); //putting the bounds in the map if(name!=null && ! name.equals("")){ map.put(name, rectBounds); } } } } } } return map; } /** * @return the display type */ protected String getWindowDisplayType(){ String display=""; Document doc=SVGResource.getXMLDocument("config.xml"); if(doc!=null){ Element root=doc.getDocumentElement(); if(root!=null){ //getting the node containing the nodes giving the bounds of the widgets in the main frame Node cur=null, displayNode=null; for(cur=root.getFirstChild(); cur!=null; cur=cur.getNextSibling()){ if(cur instanceof Element && cur.getNodeName().equals("display")){ displayNode=cur; break; } } if(displayNode!=null){ display=((Element)cur).getAttribute("type"); } } } return display; } /** * closes all the opened svg files */ public void closeAll() { Object obj=null; if(getSVGModuleLoader()!=null){ obj=getSVGModuleLoader().getModule("SaveClose"); } if(obj!=null){ Class[] cargs={}; Object[] args={}; try{ obj.getClass().getMethod("closeAllAction", cargs).invoke(obj,args); }catch (Exception ex){} } } /** * saves the file of the given frame * @param frame a frame */ public void saveFrame(SVGFrame frame) { if(frame!=null) { //getting the save module Object obj=null; if(getSVGModuleLoader()!=null){ obj=getSVGModuleLoader().getModule("SaveClose"); } if(obj!=null){ //invoking the save action Class[] cargs={SVGFrame.class, boolean.class, boolean.class}; Object[] args={frame, false, false}; try{ obj.getClass().getMethod("saveAction", cargs).invoke(obj,args); }catch (Exception ex){ex.printStackTrace();} } } } /** * opens the * @param path */ public void openFile(final String path) { SwingUtilities.invokeLater(new Runnable() { public void run() { if(path!=null && ! path.equals("")) { setVisible(true); Object obj=moduleManager.getModule("NewOpen"); File file=null; try{file=new File(new URI(path));}catch (Exception ex){} if(obj!=null){ Class[] cargs={File.class}; Object[] args={file}; try{ obj.getClass().getMethod("open",cargs).invoke(obj,args); }catch (Exception e){} } } } }); } /** * @param name the name of a widget * @return the preferred bounds of a widget */ public Rectangle getPreferredWidgetBounds(String name){ Rectangle rect=null; if(name!=null && ! name.equals("")){ try{ rect=widgetBounds.get(name); }catch (Exception ex){rect=null;} } return rect; } /** * @return the component into which all the panels containing the JScrollPanes will be placed */ public JComponent getDesktop(){ return desktop; } /** * @return the menubar */ public SVGMenuBar getMenuBar(){ return moduleManager.getMenuBar(); } /** * @return the tool bar */ public SVGEditorToolbars getEditorToolBars(){ return moduleManager.getEditorToolBars(); } /** * @return the popup manager */ public SVGPopup getPopupManager() { return moduleManager.getPopupManager(); } /** * @return Returns the resourceImageManager. */ public SVGResourceImageManager getResourceImageManager() { return moduleManager.getResourceImageManager(); } /** * @return the module loader */ public SVGModuleManager getSVGModuleLoader(){ return moduleManager; } /** * @return the toolkit object containing utility methods */ public SVGToolkit getSVGToolkit(){ return toolkit; } /** * @return the painter manager */ public static SVGColorManager getSVGColorManager(){ return moduleManager.getColorManager(); } /** * @return the manager of the cursors */ public SVGCursors getCursors(){ return moduleManager.getCursors(); } /** * @return an object of the class managing the resources */ public SVGResource getResource(){ return resource; } /** * used to call the same method on each module * @param method the method name * @param cargs an array of Class objects * @param args an array of objects */ public void invokeOnModules(String method, Class[] cargs, Object[] args){ Collection modules=moduleManager.getModules(); Iterator it=modules.iterator(); Object current=null; while(it.hasNext()){ current=it.next(); try{ Method meth=current.getClass().getMethod(method,cargs); //invokes the method on each instance contained in the map meth.invoke(current,args); }catch (Exception ex){} } } /** * @return the collection of the shape modules */ public Collection getShapeModules(){ return moduleManager.getShapeModules(); } /** * cancels all the actions that could be running and enables the regular selection mode * if the boolean is true, disables it otherwise * @param enableRegularMode true to enable the regular selection mode */ public void cancelActions(boolean enableRegularMode){ //invokes the "cancelActions" on each module Collection modules=getSVGModuleLoader().getModules(); SVGModule module=null; for(Iterator it=modules.iterator(); it.hasNext();){ try{ module=(SVGModule)it.next(); }catch (Exception ex){module=null;} if(module!=null){ module.cancelActions(); } } if(getSVGSelection()!=null){ getSVGSelection().setSelectionEnabled(enableRegularMode); } if(isMultiWindow()){ getEditorToolBars().cancelActions(); } } /** * @param name the name of the module * @return the module object */ public Object getModule(String name){ return moduleManager.getModule(name); } /** * @param name the name of the shape module * @return the shape module object */ public SVGShape getShapeModule(String name){ return moduleManager.getShapeModule(name); } /** * @return the static undoRedo module */ public SVGUndoRedo getUndoRedo(){ return undoRedo; } /** * @return the static selection module */ public SVGSelection getSVGSelection(){ return selection; } /** * @return Returns the format. */ public static DecimalFormat getFormat() { return format; } /** * @return the format used when numbers have to be displayed */ public static DecimalFormat getDisplayFormat() { return displayFormat; } /** * exits the editor */ public void exit(){ //saving the current state of the editor editor.getResource().saveEditorsCurrentState(); if(isQuitActionDisabled()) { //hiding the editor's frame setVisible(false); }else { //quitting the editor //checks if some svg documents have been modified boolean displayDialog=false; Collection<SVGFrame> frames=new LinkedList<SVGFrame>(editor.getFrameManager().getFrames()); if(frames!=null && frames.size()>0){ for(SVGFrame frm : frames){ if(frm!=null && frm.isModified()){ displayDialog=true; break; } } } boolean canExitEditor=canExitFromJVM; //if svg documents have been modified, display an alert dialog if(displayDialog){ String messageexit="", titleexit=""; if(bundle!=null){ try{ messageexit=bundle.getString("messageexit"); titleexit=bundle.getString("titleexit"); }catch (Exception ex){} } int returnVal=JOptionPane.showConfirmDialog(getParent(), messageexit, titleexit, JOptionPane.YES_NO_OPTION); canExitEditor=canExitEditor && returnVal==JOptionPane.YES_OPTION; } if(canExitEditor) { //running the dispose runnables for(Runnable runnable : disposeRunnables){ runnable.run(); } System.exit(0); } } } /** * @return the svg editor */ public static SVGEditor getSVGEditor() { return editor; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -