Author: pwang
Date: 2010-06-28 13:24:15 -0700 (Mon, 28 Jun 2010)
New Revision: 20690

Modified:
   cytoscape/trunk/src/cytoscape/data/CyAttributesUtils.java
Log:
Add a new method

Modified: cytoscape/trunk/src/cytoscape/data/CyAttributesUtils.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/CyAttributesUtils.java   2010-06-28 
20:23:15 UTC (rev 20689)
+++ cytoscape/trunk/src/cytoscape/data/CyAttributesUtils.java   2010-06-28 
20:24:15 UTC (rev 20690)
@@ -838,4 +838,43 @@
                        attrs.getMultiHashMap().setAttributeValue(copyID, 
attrName, visitedValue, keySpace);
                }
        }
+       
+       
+       /**
+        * Check if all the values for an attribute are NULL.
+        * @param attributeType     "node" or "edge"
+        * @param attributeName         attribute name.
+        */
+       public static boolean isNullAttribute(String attributeType, String 
attributeName){
+               
+               boolean retValue = true;
+                                               
+               CyAttributes attributes = null;
+               if (attributeType.equalsIgnoreCase("node")){
+                       attributes = Cytoscape.getNodeAttributes();
+                       int[] nodeIndices = 
Cytoscape.getCurrentNetwork().getNodeIndicesArray();
+                       for (int i=0; i<nodeIndices.length; i++){
+                               String nodeID = 
Cytoscape.getRootGraph().getNode(nodeIndices[i]).getIdentifier();
+                               Object valueObj = 
attributes.getAttribute(nodeID, attributeName);
+                               if (valueObj != null){
+                                       retValue = false;
+                                       break;
+                               }
+                       }
+               }
+               else {// edge
+                       attributes = Cytoscape.getEdgeAttributes();             
        
+                       int[] edgeIndices = 
Cytoscape.getCurrentNetwork().getEdgeIndicesArray();
+                       for (int i=0; i<edgeIndices.length; i++){
+                               String edgeID = 
Cytoscape.getRootGraph().getEdge(edgeIndices[i]).getIdentifier();
+                               Object valueObj = 
attributes.getAttribute(edgeID, attributeName);
+                               if (valueObj != null){
+                                       retValue = false;
+                                       break;
+                               }
+                       }
+               }
+
+               return retValue;
+       }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to cytoscape-...@googlegroups.com.
To unsubscribe from this group, send email to 
cytoscape-cvs+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to