import vtk.vtkProp;
-public abstract class AbstractVTKNodeMap<E extends INode> implements VTKNodeMap<E>, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{
+public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VTKNodeMap<DBObject,E>, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{
private static final boolean DEBUG = false;
protected Session session;
- protected IMapping<Object,E> mapping;
+ protected IMapping<DBObject,E> mapping;
protected VtkView view;
- protected MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
- protected Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
+ private MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
+ private Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
protected ParentNode<E> rootNode;
protected int redoOpCount = 0;
protected boolean runUndo = false;
protected boolean runRedo = false;
- public AbstractVTKNodeMap(Session session, IMapping<Object,E> mapping, VtkView view, ParentNode<E> rootNode) {
+ public AbstractVTKNodeMap(Session session, IMapping<DBObject,E> mapping, VtkView view, ParentNode<E> rootNode) {
this.session = session;
this.mapping = mapping;
this.view = view;
e.printStackTrace();
}
}
-
-
-
+
protected abstract void addActor(E node);
protected abstract void removeActor(E node);
protected abstract void updateActor(E node,Set<String> ids);
return nodeToActor.getValues((E)node);
}
+ protected <T extends vtkProp> void map(E node, Collection<T> props) {
+ for (vtkProp p : props) {
+ nodeToActor.add(node, p);
+ actorToNode.put(p, node);
+ }
+ }
+
+ protected void removeMap(E node) {
+ Collection<vtkProp> coll = nodeToActor.getValuesUnsafe(node);
+ for (vtkProp p : coll) {
+ actorToNode.remove(p);
+ }
+ nodeToActor.remove(node);
+ }
+
@SuppressWarnings("unchecked")
@Override
public ParentNode<E> getRootNode() {
added.add(new Pair<E, String>(node, id));
rangeModified = true;
}
- view.refresh();
+ repaint();
}
@SuppressWarnings("unchecked")
protected void reset(ReadGraph graph) throws MappingException {
if (DEBUG) System.out.println("Reset");
+
synchronized (syncMutex) {
graphUpdates = true;
mapping.getRangeModified().clear();
- for (Object o : mapping.getDomain())
+ for (DBObject o : mapping.getDomain())
mapping.domainModified(o);
mapping.updateRange(graph);
graphModified.clear();
} else {
synchronized (syncMutex) {
graphUpdates = true;
- for (Object domainObject : mapping.getDomainModified()) {
+ for (DBObject domainObject : mapping.getDomainModified()) {
E rangeObject = mapping.get(domainObject);
if (rangeObject != null)
graphModified.add(rangeObject);
/**
* When objects are removed (either from Java or Graph), after remove processing the Java objects remain in mapping cache.
- * This causes problems with Undo and Redo, whcih the end up re-using the removed objects from mapping cache.
+ * This causes problems with Undo and Redo, which cause re-using the removed objects from mapping cache.
*
* This code here synchronizes removed and added objects to collect deletable objects. (a deletable object is one which is removed but not added).
*
}
- public IMapping<Object,E> getMapping() {
+ public IMapping<DBObject,E> getMapping() {
return mapping;
}