1 19 package org.lucane.applications.whiteboard.operations; 20 21 import org.lucane.applications.whiteboard.graph.MyGraph; 22 import org.lucane.applications.whiteboard.operations.changers.*; 23 24 import java.util.*; 25 26 import org.jgraph.event.GraphModelEvent; 27 import org.jgraph.graph.*; 28 29 public class GraphInsert implements GraphOperation 30 { 31 private Object [] inserted; 32 private Map attributes; 33 private ConnectionSet connectionSet; 34 private ParentMap parentMap; 35 36 public void init(GraphModelEvent gme) 37 { 38 GraphModelEvent.GraphModelChange change = gme.getChange(); 39 40 this.inserted = change.getInserted(); 41 this.attributes = change.getPreviousAttributes(); 42 this.connectionSet = change.getPreviousConnectionSet(); 43 this.parentMap = change.getPreviousParentMap(); 44 } 45 46 public void apply(MyGraph graph) 47 { 48 GraphModel model = graph.getModel(); 49 for(int i=0;i<inserted.length;i++) 50 { 51 if(inserted[i] == null) 52 continue; 53 54 GraphCell gc = (GraphCell)inserted[i]; 55 Changer changer = ChangerFactory.getChanger(gc); 56 changer.change(graph, gc, gc); 57 } 58 59 model.insert(inserted, attributes, connectionSet, parentMap, null); 60 } 61 } | Popular Tags |