📄 svgselection.java~1~
字号:
lastSelectedNodes.clear(); lastSelectedNodes.addAll(list); for(Iterator it=new LinkedList(selectionListeners).iterator(); it.hasNext();){ ((ActionListener)it.next()).actionPerformed(null); } } } /** * adds selection squares to the map * @param frame a frame * @param map the map of the selection squares */ public void addSelectionSquares(SVGFrame frame, Hashtable map){ if(frame!=null && map!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.addSelectionSquares(map); } } } /** * @return whether an action is currently being done or not on any of the canvases */ public boolean isActing(){ boolean isActing=false; SVGSelectionManager selectionManager=null; for(Iterator it=selectionManagers.values().iterator(); it.hasNext();){ try{ selectionManager=(SVGSelectionManager)it.next(); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null && selectionManager.isActing()){ isActing=true; break; } } return isActing; } /** * refreshes the selection * @param frame a frame */ public void refreshSelection(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.refreshSelection(); } } } /** adds or removes a node from the selected nodes * @param frame the current SVGFrame * @param element the element that will be handled */ public void handleNodeSelection(SVGFrame frame, Element element){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.handleNodeSelection(element, false, true, false); } } } /** * adds an undo/redo action to the action list * @param frame the current SVGFrame * @param action the action to be added */ public void addUndoRedoAction(SVGFrame frame, SVGUndoRedoAction action){ if(frame!=null && action!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.addUndoRedoAction(action); } } } /** * gets the list of the currently selected nodes * @param frame the current SVGFrame * @return the list of the currently selected nodes */ public LinkedList<Element> getCurrentSelection(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ return selectionManager.getCurrentSelection(); } } return null; } /** * gets the list of the currently selected nodes * @param frame the current SVGFrame * @return the list of the currently selected nodes */ protected Map getSelectionMap(SVGFrame frame){ Map map=new HashMap(); if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ map=selectionManager.getCurrentSelectionTypeMap(); } } return map; } /** * returns the current parent element for the given frame (the root element of a svg document, or a g node) * @param frame * @return the current parent element for the given frame (the root element of a svg document, or a g node) */ public Element getCurrentParentElement(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ return selectionManager.getParentElement(); } } return null; } /** * enters a group if the selection contains a single g node * @param frame */ public void enterGroup(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.enterGroup(); } } } /** * exits the current edited group * @param frame */ public void exitGroup(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.exitGroup(); } } } /** * deselects all the nodes contained in the svg document of the given frame * @param frame * @param pushUndoRedoAction whether an undo/redo action should be added to the stack* * @param executeWhenNoNodesSelected whether to execute this method even if no node is selected */ public void deselectAll(SVGFrame frame, boolean pushUndoRedoAction, boolean executeWhenNoNodesSelected){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.deselectAll(pushUndoRedoAction, executeWhenNoNodesSelected); } } } /** * selects all the children of the root element * @param frame the current SVGFrame * @param pushUndoRedoAction whether an undo/redo action should be added to the stack */ public void selectAll(SVGFrame frame, boolean pushUndoRedoAction){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.selectAll(pushUndoRedoAction); } } } /** * draws a rectangle representing the selected area while dragging * @param gr a graphics element * @param bounds the bounds of the rectangle to be drawned */ public void drawSelectionGhost(Graphics gr, Rectangle2D.Double bounds){ Graphics2D g=(Graphics2D)gr.create(); if(g!=null && bounds!=null){ //draws the new awt rectangle to be displayed g=(Graphics2D)g.create(); g.setColor(LINE_SELECTION_COLOR); g.setXORMode(Color.white); //g.setStroke(lineStroke); g.drawRect((int)bounds.x, (int)bounds.y, (int)bounds.width, (int)bounds.height); g.dispose(); } } /** * locks the node of the current selection * @param frame the current SVGFrame */ public void lock(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.lock(); } } } /** * unlocks the locked nodes of the current selection * @param frame the current SVGFrame */ public void unlock(SVGFrame frame){ if(frame!=null){ SVGSelectionManager selectionManager=null; try{ selectionManager=(SVGSelectionManager)selectionManagers.get(frame); }catch (Exception ex){selectionManager=null;} if(selectionManager!=null){ selectionManager.unlock(); } } } @Override public void cancelActions(){ if(getSVGEditor().getFrameManager().getCurrentFrame()!=null){ //resets the help information displayed getSVGEditor().getFrameManager().getCurrentFrame().getStateBar().setSVGInfos(""); getSVGEditor().getFrameManager().getCurrentFrame().getStateBar().setSVGW(""); getSVGEditor().getFrameManager().getCurrentFrame().getStateBar().setSVGH(""); getSVGEditor().getFrameManager().getCurrentFrame().getScrollPane().getSVGCanvas().setEnableWaitCursor(true); regularModeTool.removeActionListener(regularModeToolListener); regularModeTool.setSelected(false); regularModeTool.addActionListener(regularModeToolListener); } } /** * enables or disables the selection actions * @param isSelectionEnabled true to enable the selection actions */ public synchronized void setSelectionEnabled(boolean isSelectionEnabled){ this.isSelectionEnabled=isSelectionEnabled; regularModeTool.setSelected(isSelectionEnabled); } /** * @return true if the selection is enabled */ public boolean isSelectionEnabled(){ return isSelectionEnabled; } /** * gets the name of the module * @return the name of the module */ public String getName(){ return idselection; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -