Search in sources :

Example 1 with EdgeView

use of org.cytoscape.ding.EdgeView in project cytoscape-impl by cytoscape.

the class DGraphView method removeEdgeView.

@Override
public EdgeView removeEdgeView(long suid) {
    final DEdgeView returnThis;
    final CyEdge edge = model.getEdge(suid);
    if (edge == null)
        return null;
    EdgeView view = edgeViewMap.get(edge);
    if (view == null)
        return null;
    getEventHelper().addEventPayload((CyNetworkView) this, (View<CyEdge>) view, AboutToRemoveEdgeViewsEvent.class);
    synchronized (m_lock) {
        returnThis = removeEdgeViewInternal(edge);
        if (returnThis != null)
            setContentChanged();
    }
    return returnThis;
}
Also used : EdgeView(org.cytoscape.ding.EdgeView) CyEdge(org.cytoscape.model.CyEdge)

Example 2 with EdgeView

use of org.cytoscape.ding.EdgeView in project cytoscape-impl by cytoscape.

the class DGraphView method syncFilterAndView.

// This is expensive and should only be called at initialization!!!
private void syncFilterAndView() {
    final List<CyNode> flaggedNodes = CyTableUtil.getNodesInState(getModel(), CyNetwork.SELECTED, true);
    final List<CyEdge> flaggedEdges = CyTableUtil.getEdgesInState(getModel(), CyNetwork.SELECTED, true);
    final List<CyNode> selectedNodes = getSelectedNodes();
    final List<CyEdge> selectedEdges = getSelectedEdges();
    // select all nodes that are flagged but not currently selected
    for (final CyNode node : flaggedNodes) {
        final NodeView nv = getDNodeView(node);
        if ((nv == null) || nv.isSelected())
            continue;
        nv.setSelected(true);
    }
    // select all edges that are flagged but not currently selected
    for (final CyEdge edge : flaggedEdges) {
        final EdgeView ev = getDEdgeView(edge);
        if ((ev == null) || ev.isSelected())
            continue;
        ev.setSelected(true);
    }
    // flag all nodes that are selected but not currently flagged
    select(selectedNodes, CyNode.class, true);
    // flag all edges that are selected but not currently flagged
    select(selectedEdges, CyEdge.class, true);
}
Also used : EdgeView(org.cytoscape.ding.EdgeView) CyNode(org.cytoscape.model.CyNode) NodeView(org.cytoscape.ding.NodeView) CyEdge(org.cytoscape.model.CyEdge)

Example 3 with EdgeView

use of org.cytoscape.ding.EdgeView in project cytoscape-impl by cytoscape.

the class DGraphView method addEdgeView.

@Override
public EdgeView addEdgeView(final CyEdge edge) {
    if (edge == null)
        throw new NullPointerException("edge is null");
    final NodeView sourceNode;
    final NodeView targetNode;
    final DEdgeView dEdgeView;
    synchronized (m_lock) {
        final EdgeView oldView = edgeViewMap.get(edge);
        if (oldView != null)
            return oldView;
        sourceNode = addNodeViewInternal(edge.getSource());
        targetNode = addNodeViewInternal(edge.getTarget());
        m_drawPersp.addEdge(edge);
        dEdgeView = new DEdgeView(this, edge, handleFactory, lexicon, serviceRegistrar);
        edgeViewMap.put(edge, dEdgeView);
        setContentChanged();
    }
    // Under no circumstances should we be holding m_lock when the listener
    // events are fired.
    /* final GraphViewChangeListener listener = m_lis[0];

		if (listener != null) {
			// Only fire this event if either of the nodes is new. The node
			// will be null if it already existed.
			if ((sourceNode != null) || (targetNode != null)) {
				long[] nodeInx;

				if (sourceNode == null) {
					nodeInx = new long[] { targetNode.getCyNode().getSUID() };
				} else if (targetNode == null) {
					nodeInx = new long[] { sourceNode.getCyNode().getSUID() };
				} else {
					nodeInx = new long[] { sourceNode.getCyNode().getSUID(),
							targetNode.getCyNode().getSUID()};
				}

				listener.graphViewChanged(new GraphViewNodesRestoredEvent(this,
						makeNodeList(nodeInx, this)));
			}

			listener.graphViewChanged(new GraphViewEdgesRestoredEvent(this,
					makeList(dEdgeView.getCyEdge())));
		}
		*/
    getEventHelper().addEventPayload((CyNetworkView) this, (View<CyEdge>) dEdgeView, AddedEdgeViewsEvent.class);
    return dEdgeView;
}
Also used : EdgeView(org.cytoscape.ding.EdgeView) NodeView(org.cytoscape.ding.NodeView) CyEdge(org.cytoscape.model.CyEdge)

Example 4 with EdgeView

use of org.cytoscape.ding.EdgeView in project cytoscape-impl by cytoscape.

the class DGraphView method getPickedEdgeView.

@Override
public EdgeView getPickedEdgeView(Point2D pt) {
    EdgeView ev = null;
    final LongStack edgeStack = new LongStack();
    queryDrawnEdges((int) pt.getX(), (int) pt.getY(), (int) pt.getX(), (int) pt.getY(), edgeStack);
    long chosenEdge = 0;
    chosenEdge = (edgeStack.size() > 0) ? edgeStack.peek() : -1;
    if (chosenEdge >= 0) {
        ev = getDEdgeView(chosenEdge);
    }
    return ev;
}
Also used : LongStack(org.cytoscape.util.intr.LongStack) EdgeView(org.cytoscape.ding.EdgeView)

Example 5 with EdgeView

use of org.cytoscape.ding.EdgeView in project cytoscape-impl by cytoscape.

the class DGraphView method getEdgeViewsList.

/**
 * Returns all edge views (including the hidden ones) that are either 1.
 * directed, having oneNode as source and otherNode as target or 2.
 * undirected, having oneNode and otherNode as endpoints. Note that this
 * behaviour is similar to that of CyNetwork.edgesList(Node, Node).
 */
@Override
public List<EdgeView> getEdgeViewsList(CyNode oneNode, CyNode otherNode) {
    synchronized (m_lock) {
        List<CyEdge> edges = model.getConnectingEdgeList(oneNode, otherNode, CyEdge.Type.ANY);
        if (edges == null) {
            return null;
        }
        final ArrayList<EdgeView> returnThis = new ArrayList<>();
        Iterator<CyEdge> it = edges.iterator();
        while (it.hasNext()) {
            CyEdge e = it.next();
            EdgeView ev = getDEdgeView(e);
            if (ev != null)
                returnThis.add(ev);
        }
        return returnThis;
    }
}
Also used : ArrayList(java.util.ArrayList) EdgeView(org.cytoscape.ding.EdgeView) CyEdge(org.cytoscape.model.CyEdge)

Aggregations

EdgeView (org.cytoscape.ding.EdgeView)6 CyEdge (org.cytoscape.model.CyEdge)5 NodeView (org.cytoscape.ding.NodeView)3 CyNode (org.cytoscape.model.CyNode)2 Point2D (java.awt.geom.Point2D)1 ArrayList (java.util.ArrayList)1 LongStack (org.cytoscape.util.intr.LongStack)1