/**
  * Finds the node hosting the selected <code>DataObject</code>.
  *
  * @param node The node to check.
  */
 private void findNode(TreeImageDisplay node) {
   if (node == null) return;
   if (parent == null) {
     Object uo = node.getUserObject();
     if (selected.getClass().equals(uo.getClass()) && selected.getId() == node.getUserObjectId()) {
       selectedNode = node;
     }
   } else {
     Object uo = node.getUserObject();
     TreeImageDisplay pN;
     if (parent instanceof String) {
       String key = parent.toString();
       if (uo instanceof DataObject) {
         pN = node.getParentDisplay();
         String n = pN.toString();
         if (key.equals(n) && selected.getId() == ((DataObject) uo).getId()) {
           selectedNode = node;
         }
       }
     } else {
       if (selected.getClass().equals(uo.getClass())
           && selected.getId() == node.getUserObjectId()) {
         pN = node.getParentDisplay();
         Object po = pN.getUserObject();
         if (po.getClass().equals(parent.getClass()))
           if (po instanceof DataObject && parent instanceof DataObject) {
             if (((DataObject) po).getId() == ((DataObject) parent).getId()) selectedNode = node;
           }
       }
     }
   }
 }
 /**
  * Finds the node hosting the selected <code>DataObject</code>.
  *
  * @param node The node to check.
  */
 private void findNodeFromSelection(TreeImageDisplay node) {
   if (node == null) return;
   Iterator<DataObject> i = selection.iterator();
   DataObject object;
   if (parent == null) {
     Object uo = node.getUserObject();
     while (i.hasNext()) {
       object = i.next();
       if (object.getClass().equals(uo.getClass()) && object.getId() == node.getUserObjectId()) {
         selectedNodes.add(node);
       }
     }
   } else {
     Object uo = node.getUserObject();
     TreeImageDisplay pN;
     if (parent instanceof String) {
       String key = parent.toString();
       if (uo instanceof DataObject) {
         pN = node.getParentDisplay();
         String n = pN.toString();
         while (i.hasNext()) {
           object = i.next();
           if (key.equals(n) && object.getId() == ((DataObject) uo).getId()) {
             selectedNodes.add(node);
           }
         }
       }
     } else {
       while (i.hasNext()) {
         object = i.next();
         if (object.getClass().equals(uo.getClass()) && object.getId() == node.getUserObjectId()) {
           pN = node.getParentDisplay();
           Object po = pN.getUserObject();
           if (po.getClass().equals(parent.getClass()))
             if (po instanceof DataObject && parent instanceof DataObject) {
               if (((DataObject) po).getId() == ((DataObject) parent).getId())
                 selectedNodes.add(node);
             }
         }
       }
     }
   }
 }
  /**
   * Returns <code>true</code> if the passed object is the reference object, <code>false</code>
   * otherwise.
   *
   * @param uo The object to compare.
   * @param ref The object of reference.
   * @return See above.
   */
  boolean isSameObject(DataObject uo, Object ref) {
    if (uo == null || !(ref instanceof DataObject)) return false;
    Class<?> klass = ref.getClass();
    DataObject object;
    if (ref instanceof WellSampleData) {
      klass = ((WellSampleData) ref).getImage().getClass();
      object = ((WellSampleData) ref).getImage();
    } else object = (DataObject) ref;

    Class<?> hoKlass = uo.getClass();
    if (uo instanceof WellSampleData) {
      hoKlass = ((WellSampleData) uo).getImage().getClass();
      uo = ((WellSampleData) uo).getImage();
    }
    if (!hoKlass.equals(klass)) return false;
    return uo.getId() == object.getId();
  }
Ejemplo n.º 4
0
 /**
  * Checks if the node is of the desired type.
  *
  * @param node The node to handle.
  */
 private void findNode(TreeImageDisplay node) {
   Object userObject = node.getUserObject();
   if (refObjects != null && refObjects.size() > 0) {
     if (userObject != null) {
       Iterator<DataObject> i = refObjects.iterator();
       DataObject object;
       Class<?> k = userObject.getClass();
       DataObject uo;
       String n = getNodeName(userObject);
       while (i.hasNext()) {
         object = i.next();
         if (object.getClass().equals(k)) {
           uo = (DataObject) userObject;
           if (byName) {
             if (n.equals(getNodeName(object))) {
               nodes.add(node);
               break;
             }
           } else {
             if (uo.getId() == object.getId()) {
               nodes.add(node);
               break;
             }
           }
         }
       }
     }
   } else {
     if (userObject != null && userObject.getClass().equals(type)) {
       if (userObject instanceof DataObject) {
         DataObject data = (DataObject) userObject;
         if (ids == null) {
           nodes.add(node);
         } else {
           if (ids.contains(data.getId())) nodes.add(node);
         }
       }
     }
   }
 }