Search in sources :

Example 1 with ViewGraphModel

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();
}
Also used : ViewGraphModel(easik.view.util.graph.ViewGraphModel) ViewFrame(easik.ui.ViewFrame) QueryNode(easik.view.vertex.QueryNode) ArrayList(java.util.ArrayList) View_Edge(easik.view.edge.View_Edge)

Example 2 with ViewGraphModel

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();
}
Also used : ViewGraphModel(easik.view.util.graph.ViewGraphModel) GraphLayoutCache(org.jgraph.graph.GraphLayoutCache) ViewFrame(easik.ui.ViewFrame) QueryNode(easik.view.vertex.QueryNode) View_Edge(easik.view.edge.View_Edge)

Aggregations

ViewFrame (easik.ui.ViewFrame)2 View_Edge (easik.view.edge.View_Edge)2 ViewGraphModel (easik.view.util.graph.ViewGraphModel)2 QueryNode (easik.view.vertex.QueryNode)2 ArrayList (java.util.ArrayList)1 GraphLayoutCache (org.jgraph.graph.GraphLayoutCache)1