use of easik.view.util.graph.ViewGraphModel in project fql by CategoricalData.
the class View method removeNode.
/**
* Removes an entity, and also cascades to remove all the arrows involved
* with it.
*
* @param toRemove
* The entity about to be removed
*/
@Override
public void removeNode(final QueryNode toRemove) {
// So we don't get a ConcurrentModificationException
final ArrayList<View_Edge> removeEdges = new ArrayList<>();
for (final View_Edge edge : _edges.values()) {
if (edge.getSourceQueryNode().equals(toRemove) || edge.getTargetQueryNode().equals(toRemove)) {
// add the edge to a list of edges to remove
removeEdges.add(edge);
}
}
model.beginUpdate();
// Remove the edges
for (final View_Edge e : removeEdges) {
removeEdge(e);
}
// remove the constraints this queryNode is a part of
for (ModelConstraint<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge> c : toRemove.getConstraints()) {
if (_constraints.containsKey(c.getID())) {
this.removeConstraint(c);
}
}
_nodes.remove(toRemove.toString());
getGraphLayoutCache().remove(new Object[] { toRemove });
// Remove Entity from tree
_Frame.getInfoTreeUI().removeNode(toRemove);
model.endUpdate();
}
use of easik.view.util.graph.ViewGraphModel in project fql by CategoricalData.
the class View method initialiseModel.
/**
* When we initialize the sketch, we flush out all the data concerning the
* sketch itself. Even the modelAdapter is reinitialized.
*
* This methods serves as a "new sketch" function.
*/
@Override
public void initialiseModel() {
clearSelection();
model = new ViewGraphModel(this);
final GraphLayoutCache glc = new GraphLayoutCache(model, new ModelViewFactory<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>());
setModel(model);
setGraphLayoutCache(glc);
_nodes = new LinkedHashMap<>();
_edges = new LinkedHashMap<>();
if (_Frame.getInfoTreeUI() != null) {
// Wipe
_Frame.setInfoTreeUI(new ModelInfoTreeUI<>(_Frame));
// Tree
_Frame.getInfoTreeUI().refreshTree();
}
_docInfo.reset();
model.discardUndo();
}
Aggregations