1 19 package org.lucane.applications.whiteboard.operations; 20 21 import org.jgraph.event.GraphModelEvent; 22 import org.jgraph.graph.DefaultGraphCell; 23 import org.jgraph.graph.DefaultGraphModel; 24 import org.jgraph.graph.GraphModel; 25 import org.lucane.applications.whiteboard.graph.GraphUtils; 26 import org.lucane.applications.whiteboard.graph.MyGraph; 27 28 public class GraphRemove implements GraphOperation 29 { 30 private Object [] removed; 31 32 public void init(GraphModelEvent gme) 33 { 34 GraphModelEvent.GraphModelChange change = gme.getChange(); 35 this.removed = change.getRemoved(); 36 } 37 38 public void apply(MyGraph graph) 39 { 40 GraphModel model = graph.getModel(); 41 for(int i=0;i<removed.length;i++) 42 { 43 if(removed[i] == null) 44 continue; 45 46 DefaultGraphCell cell = (DefaultGraphCell)removed[i]; 47 removed[i] = GraphUtils.findCorrespondingCell(graph, cell); 48 } 49 model.remove(removed); 51 } 52 } | Popular Tags |