コード例 #1
0
ファイル: GraphVisualizer.java プロジェクト: mcgrew/bionet
 public void stateChanged(PickedStateChangeEvent<V> event) {
   // check to see if a vertex was added to or taken away from the selection.
   // if one was added, we can improve performance by simply removing nodes
   // from the NeighborCollection which are not neighbors of the new node.
   if (event.getStateChange()) {
     if (graph.getPickedVertexState().getPicked().size() == 1) {
       Collection newNeighbors = graph.getNeighbors(event.getItem());
       if (newNeighbors != null) this.addAll(newNeighbors);
     } else {
       for (V v : new Vector<V>(this)) {
         this.remove(event.getItem());
         try {
           if (!graph.isNeighbor(event.getItem(), v)) this.remove(v);
         } catch (IllegalArgumentException e) {
         }
       }
     }
   } else {
     this.update();
   }
 }