Author: scooter
Date: 2011-08-26 17:14:55 -0700 (Fri, 26 Aug 2011)
New Revision: 26642

Modified:
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
Log:
Changed so that individual metanodes remember whether they are aggregating or 
not.


Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
       2011-08-26 23:23:24 UTC (rev 26641)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
       2011-08-27 00:14:55 UTC (rev 26642)
@@ -627,7 +627,7 @@
                        String aggrType = args.get(AGGREGATION).toString();
                        AttributeHandlingType aggr = getAggregation(type, 
aggrType);
                        AttributeManager manager = 
MetaNodeManager.getDefaultAttributeManager();
-                       manager.addHandler(attr, aggr);
+                       manager.addHandler(null, attr, aggr);
                        result.addMessage("metanode: set attribute aggretion 
for "+attr+" to "+aggr.toString());
                }
 

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
 2011-08-26 23:23:24 UTC (rev 26641)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
 2011-08-27 00:14:55 UTC (rev 26642)
@@ -55,6 +55,7 @@
  */
 public class AttributeManager {
        static public final String OVERRIDE_ATTRIBUTE = "__MetanodeAggregation";
+       static public final String ENABLE_ATTRIBUTE = 
"__MetanodeAggregationEnabled";
        static public final String CHILDREN_ATTRIBUTE = "NumChildren";
        static public final String DESCENDENTS_ATTRIBUTE = "NumDescendents";
 
@@ -163,10 +164,11 @@
         * Add a new handler to our internal map for aggregating the designated
         * attribute and handlerType
         *
+        * @param metaContext the metanode context for this handler
         * @param attribute the attribute this handler is for
         * @param handlerType the aggregation method for use by the handler
         */
-       public void addHandler(String attribute, AttributeHandlingType 
handlerType) {
+       public void addHandler(MetaNode metaContext, String attribute, 
AttributeHandlingType handlerType) {
                if (handlerMap == null) handlerMap = new HashMap();
 
                if (handlerMap.containsKey(attribute)) {
@@ -174,17 +176,27 @@
                } else {
                        handlerMap.put(attribute, new 
AttributeHandler(attribute, handlerType));
                }
-               
-               // Update our list of overrides in the network attributes
-               CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
 
-               // Make sure we have a network to work with
-               if (network == null)
-                       network = Cytoscape.getCurrentNetwork();
-               if (networkAttributes.hasAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE)) {
-                       Map<String,String> attrMap = 
(Map<String,String>)networkAttributes.getMapAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE);
-                       attrMap.put(attribute, handlerType.toString());
-                       
networkAttributes.setMapAttribute(network.getIdentifier(), OVERRIDE_ATTRIBUTE, 
attrMap);
+               if (metaContext == null) {
+                       // Update our list of overrides in the network 
attributes
+                       CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
+
+                       // Make sure we have a network to work with
+                       if (network == null)
+                               network = Cytoscape.getCurrentNetwork();
+                       if 
(networkAttributes.hasAttribute(network.getIdentifier(), OVERRIDE_ATTRIBUTE)) {
+                               Map<String,String> attrMap = 
(Map<String,String>)networkAttributes.getMapAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE);
+                               attrMap.put(attribute, handlerType.toString());
+                               
networkAttributes.setMapAttribute(network.getIdentifier(), OVERRIDE_ATTRIBUTE, 
attrMap);
+                       }
+               } else {
+                       CyAttributes nodeAttributes = 
Cytoscape.getNodeAttributes();
+                       String metaNode = 
metaContext.getGroupNode().getIdentifier();
+                       if (nodeAttributes.hasAttribute(metaNode, 
OVERRIDE_ATTRIBUTE)) {
+                               Map<String,String> attrMap = 
(Map<String,String>)nodeAttributes.getMapAttribute(metaNode, 
OVERRIDE_ATTRIBUTE);
+                               attrMap.put(attribute, handlerType.toString());
+                               nodeAttributes.setMapAttribute(metaNode, 
OVERRIDE_ATTRIBUTE, attrMap);
+                       }
                }
        }
 
@@ -246,8 +258,10 @@
         * the network attributes for this network.
         *
         * @param network the CyNetwork we're going to read our options from
+        * @param metaContext the metaNode we're referring to.  If null, we 
want the network.
         */
-       public void loadHandlerMappings(CyNetwork network) {
+       public void loadHandlerMappings(CyNetwork network, MetaNode 
metaContext) {
+               // Load the network defaults
                CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
                this.network = network;
                if (networkAttributes.hasAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE)) {
@@ -256,6 +270,24 @@
                                handlerMap.put(attr, new AttributeHandler(attr, 
stringToType(attrMap.get(attr))));
                        }
                }
+               if (metaContext == null) return;
+
+               // Now load our specific overrides
+               CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
+               String metaNode = metaContext.getGroupNode().getIdentifier();
+               if (nodeAttributes.hasAttribute(metaNode, OVERRIDE_ATTRIBUTE)) {
+                       Map<String,String> attrMap = 
(Map<String,String>)nodeAttributes.getMapAttribute(metaNode, 
OVERRIDE_ATTRIBUTE);
+                       for (String attr: attrMap.keySet()) {
+                               handlerMap.put(attr, new AttributeHandler(attr, 
stringToType(attrMap.get(attr))));
+                       }
+               }
+               this.aggregating = false;
+               if (nodeAttributes.hasAttribute(metaNode, ENABLE_ATTRIBUTE)) {
+                       // System.out.println(ENABLE_ATTRIBUTE+" for 
"+metaNode+" is "+nodeAttributes.getBooleanAttribute(metaNode, 
ENABLE_ATTRIBUTE));
+                       if (nodeAttributes.getBooleanAttribute(metaNode, 
ENABLE_ATTRIBUTE)) {
+                               this.aggregating = true;
+                       }
+               }
        }
 
        /**
@@ -310,7 +342,7 @@
        }
 
        /**
-        * Update all of the attributes for a particular metanode.  This 
includes the inform
+        * Update all of the attributes for a particular metanode.  This 
includes the info
         * on the number of children and the number of descendents as well as 
handling all of the 
         * attribute aggregation.
         *
@@ -346,6 +378,12 @@
                if (getEnable()) {
                        // Update all of the node attributes
                        assignAttributes(nodeAttributes, metaNodeName);
+                       nodeAttributes.setAttribute(metaNodeName, 
DESCENDENTS_ATTRIBUTE, new Integer(nDescendents));
+                       nodeAttributes.setAttribute(metaNodeName, 
ENABLE_ATTRIBUTE, Boolean.TRUE);
+                       // System.out.println("Setting "+ENABLE_ATTRIBUTE+" for 
"+metaNodeName+" to "+Boolean.TRUE);
+               } else {
+                       // System.out.println("Setting "+ENABLE_ATTRIBUTE+" for 
"+metaNodeName+" to "+Boolean.FALSE);
+                       nodeAttributes.setAttribute(metaNodeName, 
ENABLE_ATTRIBUTE, Boolean.FALSE);
                }
 
                // Update our special attributes
@@ -403,6 +441,9 @@
                                        String source,
                                        MetaNode recurse) {
 
+               if (handler == null) 
+                       return;
+
                if (recurse == null) {
                        Object value = handler.aggregateAttribute(attrMap, 
source, 1);
                        return;

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-08-26 23:23:24 UTC (rev 26641)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-08-27 00:14:55 UTC (rev 26642)
@@ -173,6 +173,7 @@
                        view = 
Cytoscape.getNetworkView(metaGroup.getNetwork().getIdentifier());
                else
                        collapsed = true;
+
                expand(view);
                collapse(view);
        }

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-08-26 23:23:24 UTC (rev 26641)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-08-27 00:14:55 UTC (rev 26642)
@@ -138,6 +138,7 @@
                mn.setChartType(chartTypeDefault);
                mn.setNodeChartAttribute(nodeChartAttributeDefault);
                mn.setAttributeManager(new 
AttributeManager(defaultAttributeManager));
+               
mn.getAttributeManager().loadHandlerMappings(metaGroup.getNetwork(), mn);
                return mn;
        }
 

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-08-26 23:23:24 UTC (rev 26641)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-08-27 00:14:55 UTC (rev 26642)
@@ -475,7 +475,7 @@
         * @param network the network we're updating our override values for
         */
        public void updateOverrides(CyNetwork network) {
-               myAttributeManager.loadHandlerMappings(network);
+               myAttributeManager.loadHandlerMappings(network, metaContext);
        }
 
        /**
@@ -674,6 +674,7 @@
                this.chartType = context.getChartType();
                this.nodeChartAttribute = context.getNodeChartAttribute();
                this.myAttributeManager = new 
AttributeManager(context.getAttributeManager());
+               
myAttributeManager.loadHandlerMappings(Cytoscape.getCurrentNetwork(), context);
        this.enableHandling = myAttributeManager.getEnable();
        }
 
@@ -685,6 +686,7 @@
                mn.setChartType(chartType);
                mn.setNodeChartAttribute(nodeChartAttribute);
                mn.setAttributeManager(myAttributeManager);
+               myAttributeManager.updateAttributes(mn);
        }
 
        private void updateDefaultSettings() {
@@ -747,7 +749,7 @@
                        AttributeHandlingType handlerType = 
(AttributeHandlingType)getListValue(t);
 
                        // Create the handler
-                       myAttributeManager.addHandler(attributeWP, handlerType);
+                       myAttributeManager.addHandler(metaContext, attributeWP, 
handlerType);
                }
                repaint();
        }

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

Reply via email to