📄 jawegraphui.java
字号:
handle.mouseDragged(e); } } else if (status == MULTIPLE_SELECTION && !aborted) { // drag rectangle for multiply selection marquee.mouseDragged(e); } e.consume(); } public void mouseReleased(MouseEvent e) { if (status == SELECTION) { if (handle != null && !aborted) { handle.mouseReleased(e); } if (selectOnRelease) {// graph.clearSelection(); selectCellForEvent(cell.getCell(), e); } } else if (status == MULTIPLE_SELECTION && graph.isSelectionEnabled() && !aborted) { marquee.mouseReleased(e); status = SELECTION; } e.consume(); } } /** * Constructs the "root handle" for <code>context</code>. * * @param context * reference to the context of the current selection. */ public CellHandle createHandle(GraphContext context) { if (context != null && !context.isEmpty() && graph.isEnabled()) return new PERootHandle(context); return null; } /** * Manages selection movement. It is adapted to suport proper * undo in coordination with WorkflowManager class. */ public class PERootHandle extends RootHandle { /** * Creates a root handle which contains handles for the given * cells. The root handle and all its childs point to the * specified JGraph instance. The root handle is responsible * for dragging the selection. */ public PERootHandle(GraphContext ctx) { super(ctx); } protected Point2D getInitialLocation(Object[] cells) { try { return super.getInitialLocation(cells); } catch (Throwable thr){ return null; } } public void mouseReleased(MouseEvent event) { if (event != null && !event.isConsumed()) { if (activeHandle != null) { activeHandle.mouseReleased(event); activeHandle = null; } else if (isMoving&& !event.getPoint().equals(start)) { if (cachedBounds != null) { int dx = event.getX()-(int)start.getX();//HM, JGraph3.4.1 int dy = event.getY()-(int)start.getY();//HM, JGraph3.4.1 Point2D tmp = graph.fromScreen(new Point(dx, dy));//HM, JGraph3.4.1 GraphLayoutCache.translateViews(views, tmp.getX(), tmp.getY());//HM, JGraph3.4.1 } // Harald Meister: snap activities to grid if grid is enabled if (GraphUtilities.getGraphController().getGraphSettings().shouldShowGrid() && views[0] instanceof GraphActivityViewInterface ){ GraphActivityViewInterface view = (GraphActivityViewInterface)views[0]; Rectangle2D rect = view.getBounds();//HM, JGraph3.4.1 int dx = 0; int dy = 0; int gridsize =GraphUtilities.getGraphController().getGraphSettings().getGridSize(); int deltax = (int)rect.getX() % gridsize; int deltay = (int)rect.getY() % gridsize; int halfgrid = gridsize / 2; if (deltax > halfgrid){ dx += (gridsize - deltax); } else { dx -= deltax; } if (deltay > halfgrid){ dy += (gridsize - deltay); } else { dy -= deltay; } Point2D tmp = graph.fromScreen(new Point(dx, dy));//HM, JGraph3.4.1 GraphLayoutCache.translateViews(views, tmp.getX(), tmp.getY());//HM, JGraph3.4.1 } // Harald Meister CellView[] all = graphLayoutCache.getAllDescendants(views); if (graph.isMoveable()){ // Move Cells //if (!graphModel.isAttributeStore()) { //Map propertyMap = GraphConstants.createPropertyMap(all,null); Map propertyMap = GraphConstants.createAttributes(all,null); GraphManager gm=getGraph().getGraphManager(); gm.moveCellsAndArrangeParticipants(propertyMap); /*} else { Map propertyMap = GraphConstants.createPropertyMap(all,null); WorkflowManager dm=getGraph().getWorkflowManager(); dm.moveCellsAndArrangeParticipants(propertyMap); }*/ } event.consume(); } } start = null; } } /** * Returns a listener that can update the graph when the view changes. */ protected GraphLayoutCacheListener createGraphLayoutCacheListener() { return new PEGraphLayoutCacheHandler(); } /** * This class observes view changes and is adapted to disallow * deselection of cells after dragging. */ public class PEGraphLayoutCacheHandler extends GraphLayoutCacheHandler { /* * (non-Javadoc) * * @see org.jgraph.event.GraphLayoutCacheListener#graphLayoutCacheChanged(org.jgraph.event.GraphLayoutCacheEvent) */ public void graphLayoutCacheChanged(GraphLayoutCacheEvent e) { Object[] changed = e.getChange().getChanged(); if (changed != null && changed.length > 0) { for (int i = 0; i < changed.length; i++) { graph.updateAutoSize(graphLayoutCache.getMapping(changed[i], false)); } } Object[] inserted = e.getChange().getInserted(); if (inserted != null && inserted.length > 0 && graphLayoutCache.isSelectsLocalInsertedCells() && !(graphLayoutCache.isSelectsAllInsertedCells() && !graphLayoutCache.isPartial()) && graph.isEnabled()) { Object[] roots = DefaultGraphModel.getRoots(graphModel, inserted); if (roots != null && roots.length > 0) { focus = graphLayoutCache.getMapping(roots[0], false); graph.setSelectionCells(roots); } } updateSize(); } } /** * Returns a listener that can update the graph when the model changes. */// protected GraphModelListener createGraphModelListener() {// return new PEGraphModelHandler();// } /** * Listens for changes in the graph model and updates the view accordingly. */ public class PEGraphModelHandler implements GraphModelListener, Serializable { public void graphChanged(GraphModelEvent e) { Object[] removed = e.getChange().getRemoved(); // Remove from selection & focus if (removed != null && removed.length > 0) { // Update Focus If Necessary for (int i = 0; i < removed.length && focus != null; i++) { if (removed[i] == focus.getCell()) { focus = null; break; } } // Remove from selection graph.getSelectionModel().removeSelectionCells(removed); } if (graphLayoutCache != null) graphLayoutCache.graphChanged(e.getChange()); // Get arrays Object[] inserted = e.getChange().getInserted(); Object[] changed = e.getChange().getChanged(); // Insert if (inserted != null && inserted.length > 0) { // Update focus to first inserted cell focus = graphLayoutCache.getMapping(inserted[0], false); for (int i = 0; i < inserted.length; i++) graph.updateAutoSize(graphLayoutCache.getMapping(inserted[i], false)); } // Change (update size) if (changed != null && changed.length > 0) { for (int i = 0; i < changed.length; i++) graph.updateAutoSize(graphLayoutCache.getMapping(changed[i], false)); } // Select if not partial if (!graphLayoutCache.isPartial() && graphLayoutCache.isSelectsAllInsertedCells() && graph.isEnabled()) {// Object[] roots = JaWEGraphModel.getRoots(graphModel, inserted);// if (roots != null && roots.length > 0) {// focus = graphLayoutCache.getMapping(roots[0], false);// graph.setSelectionCells(roots);// } graph.setSelectionCells(inserted); } updateSize(); } } // End of BasicGraphUI.GraphModelHandler public void reset() { status = ((GraphMarqueeHandler) marquee).getStatus(); } /** * Creates the listener reponsible for getting key events from the graph. */ protected KeyListener createKeyListener() { return new PEKeyHandler(); } /** * This is used to get multiple key down events to appropriately generate * events. */ public class PEKeyHandler extends KeyAdapter implements Serializable { /** Key code that is being generated for. */ protected Action repeatKeyAction; /** Set to true while keyPressed is active. */ protected boolean isKeyDown; public void keyPressed(KeyEvent e) { KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); if (keyStroke.getKeyCode() == KeyEvent.VK_ESCAPE) { if (marquee != null) marquee.mouseReleased(null); ((GraphMarqueeHandler)marquee).setSelectionMode(); aborted = true; } } public void keyReleased(KeyEvent e) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -