/**
  * Deselects all graph cells that have the same userObject as specified in the parameter.
  *
  * @param root The graph cell whose userObject will be considered.
  */
 private void removeAll(Object root) {
   if (root != null) {
     if (root instanceof DefaultGraphCell) {
       // the cell is a DefaultGraphCell
       DefaultGraphCell rootCell = (DefaultGraphCell) root;
       // get all graph cells that have the same userObject like the rootCell
       List<Object> list = getCellsWithUserObject(rootCell);
       if (list != null) {
         // deselect all the graph cells with the same userObject
         graph.getSelectionModel().removeSelectionCells(list.toArray());
       }
     }
   }
 }
 /**
  * Cretes a new instance for the specified graph. Assignes self as a listener for the graph.
  *
  * @param aGraph The graph that is listened to.
  */
 public DGraphSelectionListener(DGraph aGraph) {
   graph = aGraph;
   graph.getSelectionModel().addGraphSelectionListener(this);
 }