/** * Standard Constructor. The argument is the graph that this filter will * apply to; it cannot be null. * * @throws NullPointerException * if the argument is null. */ public SelectFilter(final GraphPerspective graph) { this.graph = graph; // this throws a NullPointerException if the graph is null graph.addGraphPerspectiveChangeListener(this); }
/** * Adds to the set of <code>giny.view.GraphView</code> objects that this * <code>GraphViewController</code> keeps synchronized to their * <code>giny.model.GraphPerspective</code> objects. The given <code>GraphViewHandler</code> * is used for the given <code>giny.view.GraphView</code> object. * * @param graph_view the <code>giny.view.GraphView</code> to be added * @param gv_to_handler the <code>GraphViewHandler</code> that will handle * change events from <code>graph_view</code>'s <code>giny.model.GraphPerspective</code> member * @return true if succesfully added, false otherwise (if <code>graph_view</code> is * already in this controller) * @see #setGraphViewHandler(GraphView, GraphViewHandler) setGraphViewHandler */ public boolean addGraphView(GraphView graph_view, GraphViewHandler gv_handler) { if (this.graphViewToHandler.containsKey(graph_view)) { // already contained return false; } GraphPerspective graphPerspective = graph_view.getGraphPerspective(); graphPerspective.addGraphPerspectiveChangeListener(this); this.gpToGv.put(graphPerspective, graph_view); this.graphViewToHandler.put(graph_view, gv_handler); return true; } //addGraphView
/** * Adds to the set of <code>giny.view.GraphView</code> objects that this * <code>GraphViewController</code> keeps synchronized with their * <code>giny.model.GraphPerspective</code> objects. * DEFAULT_GRAPH_VIEW_HANDLER is used for the given <code>giny.view.GraphView</code> * * @param graph_view the <code>giny.view.GraphView</code> to be added * @return true if succesfully added, false otherwise (if it was already added) * @see GraphViewController.setGraphViewHandler */ public boolean addGraphView(GraphView graph_view) { if (this.graphViewToHandler.containsKey(graph_view)) { // already contained in this controller return false; } GraphPerspective graphPerspective = graph_view.getGraphPerspective(); graphPerspective.addGraphPerspectiveChangeListener(this); this.gpToGv.put(graphPerspective, graph_view); this.graphViewToHandler.put(graph_view, DEFAULT_GRAPH_VIEW_HANDLER); return true; } //addGraphView
/** * It adds this <code>GraphViewController</code> listener to the * <code>giny.model.GraphPerspective</code> of the given <code>giny.view.GraphView</code> * that was temporarily "removed" by a call to <code>stopListening(GraphView)</code>, it updates * <code>graph_view</code> so that it's synchronized to its <code>GraphPerspective</code> * due to changes that may have occured while not listening. * * @see #stopListening(GraphView) */ public void resumeListening(GraphView graph_view) { GraphViewHandler handler = (GraphViewHandler) this.graphViewToHandler.get(graph_view); handler.updateGraphView(graph_view); GraphPerspective graphPerspective = graph_view.getGraphPerspective(); graphPerspective.addGraphPerspectiveChangeListener(this); } //resumeListening
/** * 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
/** * 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