/** * TO keep things clearer there is one GraphView Controller per * CytoscapeDesktop */ public GraphViewController getGraphViewController() { if (graphViewController == null) graphViewController = new GraphViewController(); return graphViewController; }
/** * Constructor, assigns <code>GraphViewController.DEFAULT_GRAPH_VIEW_HANDLER</code> * to all the given <code>giny.view.GraphView</code> objects in the array. * * @param graph_views an array of <code>giny.view.GraphView</code> objects * that this <code>GraphViewController</code> will keep synchronized to * their corresponding <code>giny.model.GraphPerspective</code> objects * available through their <code>getGraphPerspective()</code> method. */ public GraphViewController(GraphView[] graph_views) { this.graphViewToHandler = new HashMap(); this.gpToGv = new HashMap(); setGraphViews(graph_views); } //GraphViewController
if (NETWORK_VIEW_CREATED.equals(e.getPropertyName())) { getGraphViewController().addGraphView((CyNetworkView) e.getNewValue()); getGraphViewController().removeGraphView((CyNetworkView) e.getNewValue());
/** * Removes all of the current <code>giny.view.GraphView</code> objects that this * <code>GraphViewController</code> keeps synchronized to their corresponding * <code>giny.model.GraphPerspective</code> members. This <code>GraphViewController</code> * will no longer receive events from <code>giny.model.GraphPerspective</code>s after * this call. * * @return the array of removed <code>giny.view.GraphView</code> objects */ public GraphView[] removeAllGraphViews() { GraphView[] gViews = getGraphViews(); for (int i = 0; i < gViews.length; i++) { GraphPerspective graphPerspective = gViews[i].getGraphPerspective(); graphPerspective.removeGraphPerspectiveChangeListener(this); } //for i this.gpToGv.clear(); this.graphViewToHandler.clear(); return gViews; } //removeAllGraphViews
/** * Sets the array of <code>giny.view.GraphView</code> objects * that this <code>GraphViewController</code> will keep synchronized with * their corresponding <code>giny.model.GraphPerspective</code> objects * available through their <code>getGraphPerspective()</code> method, the * DEFAULT_GRAPH_VIEW_HANDLER is set for all the views. Any previous <code>GraphView</code> * objects are removed from this listener * * @param graph_views an array of <code>giny.view.GraphView</code> objects */ public void setGraphViews(GraphView[] graph_views) { removeAllGraphViews(); for (int i = 0; i < graph_views.length; i++) { GraphPerspective graphPerspective = graph_views[i].getGraphPerspective(); graphPerspective.addGraphPerspectiveChangeListener(this); this.gpToGv.put(graphPerspective, graph_views[i]); this.graphViewToHandler.put(graph_views[i], DEFAULT_GRAPH_VIEW_HANDLER); } //for i } //setGraphViews
/** * It temporarily removes this <code>GraphViewController</code> as a listener for * all <code>giny.model.GraphPerspective</code> objects that it currently * listens to * * @see #resumeListening() resumeListening */ public void stopListening() { GraphView[] graphViews = getGraphViews(); for (int i = 0; i < graphViews.length; i++) { GraphPerspective graphPerspective = graphViews[i].getGraphPerspective(); graphPerspective.removeGraphPerspectiveChangeListener(this); } //for i } //stopListening
/** * Sets the array of <code>giny.view.GraphView</code> objects * that this <code>GraphViewController</code> will keep synchronized with * their corresponding <code>giny.model.GraphPerspective</code> objects * available through their <code>getGraphPerspective()</code> method, the * <code>cytoscape.view.GraphViewHandler</code> objects for the * <code>GraphView</code>s are obtained from the given <code>Map</code>, * if a <code>GraphView</code> in the array is not a key in the <code>Map</code> * then DEFAULT_GRAPH_VIEW_HANDLER is used. Any previous <code>GraphView</code> * objects are removed from this listener * * @param graph_views an array of <code>giny.view.GraphView</code> objects * @param gv_to_handler a <code>Map</code> with <code>giny.view.GraphView</code> * for keys and <code>cytoscape.view.GraphViewHandler</code> objects for values */ public void setGraphViews(GraphView[] graph_views, Map gv_to_handler) { removeAllGraphViews(); for (int i = 0; i < graph_views.length; i++) { GraphPerspective graphPerspective = graph_views[i].getGraphPerspective(); graphPerspective.addGraphPerspectiveChangeListener(this); this.gpToGv.put(graphPerspective, graph_views[i]); GraphViewHandler handler = (GraphViewHandler) gv_to_handler.get(graph_views[i]); if (handler == null) { this.graphViewToHandler.put(graph_views[i], DEFAULT_GRAPH_VIEW_HANDLER); } else { this.graphViewToHandler.put(graph_views[i], handler); } } //for i } //setGraphViews
/** * It adds this <code>GraphViewController</code> as a listener for * all <code>giny.model.GraphPerspective</code> that were temporarily * "removed" by calling <code>stopListening()</code>, it updates the <code>GraphViews</code> * of the <code>GraphPerspectives</code> so that they are synchronized to reflect changes that * may have occured while not listening. * * @see #stopListening() stopListening */ public void resumeListening() { GraphView[] graphViews = getGraphViews(); for (int i = 0; i < graphViews.length; i++) { GraphPerspective graphPerspective = graphViews[i].getGraphPerspective(); GraphViewHandler handler = (GraphViewHandler) this.graphViewToHandler.get(graphViews[i]); handler.updateGraphView(graphViews[i]); graphPerspective.addGraphPerspectiveChangeListener(this); } //for i } //resumeListening
/** * Constructor, specifies the <code>cytoscape.view.GraphViewHandler</code> objects * for the given <code>giny.view.GraphView</code> objects in the arrays. * * @param graph_views an array of <code>giny.view.GraphView</code> objects * that this <code>GraphViewController</code> will keep synchronized to * their corresponding <code>giny.model.GraphPerspective</code> objects * available through their <code>getGraphPerspective()</code> method * @param gv_to_handler a <code>Map</code> with <code>giny.view.GraphView</code> * objects as keys, and <code>cytoscape.view.GraphViewHandler</code> objects * as values, two or more different keys can share the same value, the * DEFAULT_GRAPH_VIEW_HANDLER will be set for <code>giny.view.GraphView</code> * objects that are not keys in the given <code>Map</code> */ public GraphViewController(GraphView[] graph_views, Map gv_to_handler) { this.graphViewToHandler = new HashMap(); this.gpToGv = new HashMap(); setGraphViews(graph_views, gv_to_handler); } //GraphViewController