private Node replaceNormalNode(
     Node normalNode, GKInstance diseaseEntity, Boolean needDashedBorder) {
   Node diseaseNode = normalToDiseaseNode.get(normalNode);
   if (diseaseNode != null) return diseaseNode;
   try {
     // If a node exists already, it should use
     for (Renderable r : diseaseComps) {
       if (diseaseEntity.getDBID().equals(r.getReactomeId()) && r instanceof Node) {
         // This is rather arbitrary: if two nodes are very close,
         // use the existing one.
         int dx = Math.abs(r.getPosition().x - normalNode.getPosition().x);
         int dy = Math.abs(r.getPosition().y - normalNode.getPosition().y);
         if (dx < 10 && dy < 10) {
           // We don't need to create a new Node if it exists already
           normalToDiseaseNode.put(normalNode, (Node) r);
           overlaidObjects.add(r); // Add it to overlaid object to cover edges
           return (Node) r;
         }
       }
     }
     diseaseNode = normalNode.getClass().newInstance();
     RenderUtility.copyRenderInfo(normalNode, diseaseNode);
     // The following should NOT be called since NodeAttachment is
     // related to disease entity only.
     // TODO: Need to support this. Currently it is not supported!!! See example
     // in PI3/AKT cancer pathway.
     // diseaseNode.setNodeAttachmentsLocally(node.getNodeAttachments());
     diseaseNode.setDisplayName(diseaseEntity.getDisplayName());
     diseaseNode.setReactomeId(diseaseEntity.getDBID());
     diseaseNode.invalidateBounds();
     diseaseNode.setRenderer(normalNode.getRenderer());
     diseaseNode.setLineColor(DefaultRenderConstants.DEFAULT_DISEASE_BACKGROUND);
     diseaseNode.setNeedDashedBorder(needDashedBorder);
     RenderUtility.hideCompartmentInNodeName(diseaseNode);
     overlaidObjects.add(diseaseNode);
     displayedObject.addComponent(diseaseNode);
     normalToDiseaseNode.put(normalNode, diseaseNode);
     return diseaseNode;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Ejemplo n.º 2
0
 private boolean isOldBoundsRecoverable() {
   if (oldIdToBounds == null || oldIdToBounds.size() == 0) return false;
   // Make sure all nodes have been registered
   if (componentsInHiearchy == null || componentsInHiearchy.size() == 0) return false;
   for (Renderable r : componentsInHiearchy) {
     if (!oldIdToBounds.containsKey(r.getID())) return false;
   }
   // Check if a complex component has the same size as its container.
   // This may occur when a hidecomponent complex forms a complex with
   // another Node.
   for (Renderable r : componentsInHiearchy) {
     if (!(r instanceof RenderableComplex)) continue;
     RenderableComplex complex = (RenderableComplex) r;
     Rectangle complexBounds = oldIdToBounds.get(complex.getID());
     List<Renderable> list = RenderUtility.getComponentsInHierarchy(complex);
     for (Renderable tmp : list) {
       Rectangle tmpBounds = oldIdToBounds.get(tmp.getID());
       if (tmpBounds.width == complexBounds.width && tmpBounds.height == complexBounds.height)
         return false;
     }
   }
   return true;
 }
Ejemplo n.º 3
0
 /**
  * Call this method to rebuild the internal hiearchy structure. This method should be called when
  * the client has a doubt regarding the internal hierarchy structure of this complex.
  */
 public void rebuildHierarchy() {
   componentsInHiearchy = RenderUtility.getComponentsInHierarchy(this);
 }