Author: scooter
Date: 2011-05-20 22:13:01 -0700 (Fri, 20 May 2011)
New Revision: 25507

Modified:
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeHandler.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
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
Log:
Make AttributeManager an instance class so we can independently
controll attributes aggregation for each meta node


Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
   2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
   2011-05-21 05:13:01 UTC (rev 25507)
@@ -257,8 +257,7 @@
        public void collapse(MetaNode metaNode, CyNetworkView view) {
                // Actually collapse the group
                metaNode.collapse(view);
-               // Handle our attributes
-               AttributeManager.updateAttributes(metaNode);
+
                if (haveNodeCharts) {
                        // Handle our node charts
                        NodeCharts.updateNodeCharts(metaNode, logger);

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
       2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/commands/MetaNodeCommandHandler.java
       2011-05-21 05:13:01 UTC (rev 25507)
@@ -97,15 +97,15 @@
        REMOVE("remove node",
               "Remove a node from a metanode",
               "metanode|node|nodelist"),
-       /* MODIFYAGG("modify aggregation", // FIXME
+       MODIFYAGG("modify aggregation",
                  "Modify the aggregation behavior of a metanode",
-                 
"metanode|enabled=true|string=csv|integer=sum|double=sum|list=none|boolean=or"),
 */
+                 
"metanode|enabled=true|string=csv|integer=sum|double=sum|list=none|boolean=or"),
        MODIFYAPP("modify appearance",
                  "Modify the appearance of a metanode",
-                 
"metanode|usenestednetworks=false|opacity=100|nodechart=none|chartattribute=none"),
-       /* MODIFYAGGOVERRIDE("modify overrides", // FIXME
+                 
"metanode|usenestednetworks=false|opacity=100|nodechart=none|chartattribute=non"),
+       MODIFYAGGOVERRIDE("modify overrides", 
                          "Modify aggregation overrides for specific attributes 
in a metanode",
-                         "metanode|attribute|aggregation"), */
+                         "metanode|attribute|aggregation"),
   SETDEFAULTAGG("set default aggregation", 
                      "Set the default aggregation options",
                      
"enabled=true|string=csv|integer=sum|double=sum|list=none|boolean=or"),
@@ -485,7 +485,8 @@
                //                "Modify the aggregation behavior of a 
metanode",
                //                
"metanode|enabled=true|string=csv|integer=sum|double=sum|list=none|boolean=or"),
                // 
-               // } else if (Command.MODIFYAGG.equals(command)) {
+               } else if (Command.MODIFYAGG.equals(command)) {
+                       setAggregation(result, metaNode, props, command, args);
 
                // 
                //      MODIFYAPP("modify appearance",
@@ -522,52 +523,30 @@
                //                        "Modify aggregation overrides for 
specific attributes in a metanode",
                //                        "metanode|attribute|aggregation"),
                // 
-               // } else if (Command.MODIFYAGGOVERRIDE.equals(command)) {
+               } else if (Command.MODIFYAGGOVERRIDE.equals(command)) {
+                       if (!args.containsKey(ATTRIBUTE))
+                               throw new RuntimeException("metanode: 
"+command+" requires an attribute");
+                       if (!args.containsKey(AGGREGATION))
+                               throw new RuntimeException("metanode: 
"+command+" requires an aggregation type");
 
+                       if (metaNode == null)
+                               throw new RuntimeException("metanode: 
"+command+" requires a metanode");
+
+                       String attr = 
getAttribute(args.get(ATTRIBUTE).toString());
+                       byte type = Cytoscape.getNodeAttributes().getType(attr);
+                       String aggrType = args.get(AGGREGATION).toString();
+                       AttributeHandlingType aggr = getAggregation(type, 
aggrType);
+                       AttributeHandler handler = 
metaNode.getAttributeManager().getHandler(attr);
+                       handler.setHandlerType(aggr);
+
                // 
                //  SETDEFAULTAGG("set default aggregation", 
                //                    "Set the default aggregation options",
                //                    
"enabled=true|string=csv|integer=sum|double=sum|list=none|boolean=or"),
                // 
                } else if (Command.SETDEFAULTAGG.equals(command)) {
-                       boolean attrHandling = false;
-                       if(args.containsKey(ENABLED))
-                               attrHandling = getBooleanArg(command, ENABLED, 
args);
+                       setAggregation(result, null, props, command, args);
 
-                       if (!attrHandling) {
-                               setTunable(props, "enableHandling", "false");
-                               result.addMessage("metanode: attribute 
aggregation disabled");
-                       } else {
-                               setTunable(props, "enableHandling", "true");
-                               result.addMessage("metanode: attribute 
aggregation enabled");
-
-                               if (args.containsKey(STRING)) {
-                                       setDefault(props, "stringDefaults", 
CyAttributes.TYPE_STRING, args.get(STRING).toString());
-                                       result.addMessage("metanode: set 
default aggregation handling for "+STRING+" to "+args.get(STRING).toString());
-                               }
-
-                               if (args.containsKey(INTEGER)) {
-                                       setDefault(props, "intDefaults", 
CyAttributes.TYPE_INTEGER, args.get(INTEGER).toString());
-                                       result.addMessage("metanode: set 
default aggregation handling for "+INTEGER+" to "+args.get(INTEGER).toString());
-                               }
-
-                               if (args.containsKey(DOUBLE)) {
-                                       setDefault(props, "doubleDefaults", 
CyAttributes.TYPE_FLOATING, args.get(DOUBLE).toString());
-                                       result.addMessage("metanode: set 
default aggregation handling for "+DOUBLE+" to "+args.get(DOUBLE).toString());
-                               }
-
-                               if (args.containsKey(LIST)) {
-                                       setDefault(props, "listDefaults", 
CyAttributes.TYPE_SIMPLE_LIST, args.get(LIST).toString());
-                                       result.addMessage("metanode: set 
default aggregation handling for "+LIST+" to "+args.get(LIST).toString());
-                               }
-
-                               if (args.containsKey(BOOLEAN)) {
-                                       setDefault(props, "booleanDefaults", 
CyAttributes.TYPE_BOOLEAN, args.get(BOOLEAN).toString());
-                                       result.addMessage("metanode: set 
default aggregation handling for "+BOOLEAN+" to "+args.get(BOOLEAN).toString());
-                               }
-                       }
-                       
-
                // 
                //      SETDEFAULTAPP("set default appearance",
                //                    "Set the default appearance options",
@@ -613,8 +592,8 @@
                        byte type = Cytoscape.getNodeAttributes().getType(attr);
                        String aggrType = args.get(AGGREGATION).toString();
                        AttributeHandlingType aggr = getAggregation(type, 
aggrType);
-                       AttributeHandler handler = 
AttributeManager.getHandler(attr);
-                       handler.setHandlerType(aggr);
+                       AttributeManager manager = 
MetaNodeManager.getDefaultAttributeManager();
+                       manager.addHandler(attr, aggr);
                        result.addMessage("metanode: set attribute aggretion 
for "+attr+" to "+aggr.toString());
                }
 
@@ -709,13 +688,62 @@
                throw new RuntimeException("metanode: unknown attribute 
type!?!");
        }
 
-       private void setDefault(MetanodeProperties props, String tunable, byte 
type, String value) {
+       private void setAggregation(CyCommandResult result, MetaNode metanode, 
MetanodeProperties props, 
+                                   String command, Map<String, Object>args) {
+               boolean attrHandling = false;
+               String messagePrefix = "metanode (default):";
+               AttributeManager attributeManager = 
MetaNodeManager.getDefaultAttributeManager();
+
+               if(args.containsKey(ENABLED))
+                       attrHandling = getBooleanArg(command, ENABLED, args);
+
+               if (metanode != null) {
+                       messagePrefix = "metanode 
("+metanode.getGroupNode().getIdentifier()+"): ";
+                       attributeManager = metanode.getAttributeManager();
+               }
+
+               if (!attrHandling) {
+                       setTunable(props, "enableHandling", "false");
+                       attributeManager.setEnable(false);
+                       result.addMessage(messagePrefix+" attribute aggregation 
disabled");
+               } else {
+                       setTunable(props, "enableHandling", "true");
+                       attributeManager.setEnable(false);
+                       result.addMessage(messagePrefix+" attribute aggregation 
enabled");
+               }
+
+               if (args.containsKey(STRING)) {
+                       setDefault(attributeManager, props, "stringDefaults", 
CyAttributes.TYPE_STRING, args.get(STRING).toString());
+                       result.addMessage(messagePrefix+" set default 
aggregation handling for "+STRING+" to "+args.get(STRING).toString());
+               }
+
+               if (args.containsKey(INTEGER)) {
+                       setDefault(attributeManager, props, "intDefaults", 
CyAttributes.TYPE_INTEGER, args.get(INTEGER).toString());
+                       result.addMessage(messagePrefix+" set default 
aggregation handling for "+INTEGER+" to "+args.get(INTEGER).toString());
+               }
+
+               if (args.containsKey(DOUBLE)) {
+                       setDefault(attributeManager, props, "doubleDefaults", 
CyAttributes.TYPE_FLOATING, args.get(DOUBLE).toString());
+                       result.addMessage(messagePrefix+" set default 
aggregation handling for "+DOUBLE+" to "+args.get(DOUBLE).toString());
+               }
+
+               if (args.containsKey(LIST)) {
+                       setDefault(attributeManager, props, "listDefaults", 
CyAttributes.TYPE_SIMPLE_LIST, args.get(LIST).toString());
+                       result.addMessage(messagePrefix+" set default 
aggregation handling for "+LIST+" to "+args.get(LIST).toString());
+               }
+
+               if (args.containsKey(BOOLEAN)) {
+                       setDefault(attributeManager, props, "booleanDefaults", 
CyAttributes.TYPE_BOOLEAN, args.get(BOOLEAN).toString());
+                       result.addMessage(messagePrefix+" set default 
aggregation handling for "+BOOLEAN+" to "+args.get(BOOLEAN).toString());
+               }
+       }
+                       
+
+       private void setDefault(AttributeManager manager, MetanodeProperties 
props, String tunable, byte type, String value) {
                // First, check to see if our value is good
                AttributeHandlingType aggrType = getAggregation(type, value);
+               manager.setDefault(type, aggrType);
 
-               // Apparently it is, so set the default
-               AttributeManager.setDefault(type, aggrType);
-
                // Now reflect the change in our tunable
                setListTunable(props, tunable, aggrType.toString());
        }

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeHandler.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeHandler.java
 2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeHandler.java
 2011-05-21 05:13:01 UTC (rev 25507)
@@ -65,7 +65,7 @@
         
*************************************************************************/
 
        protected AttributeHandler (String attribute, AttributeHandlingType 
type) {
-               this.attribute = attribute.substring(5); // Skip over type
+               this.attribute = attribute;
                this.type = type;
                this.count = 0;
                aggregateValue = null;

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
 2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/data/AttributeManager.java
 2011-05-21 05:13:01 UTC (rev 25507)
@@ -54,15 +54,16 @@
  * themselves handle the aggregation of attributes.
  */
 public class AttributeManager {
-       static private Map<String, AttributeHandler>handlerMap = null;
-       static private Map<String, AttributeHandler>saveHandlerMap = null;
-       static private AttributeHandlingType[] defaultHandling = new 
AttributeHandlingType[15];
-       static private boolean aggregating = false;
-       static private CyNetwork network;
        static public final String OVERRIDE_ATTRIBUTE = "__MetanodeAggregation";
        static public final String CHILDREN_ATTRIBUTE = "NumChildren";
        static public final String DESCENDENTS_ATTRIBUTE = "NumDescendents";
 
+       private AttributeHandlingType[] defaultHandling = new 
AttributeHandlingType[15];
+       private Map<String, AttributeHandler>handlerMap = null;
+       private Map<String, AttributeHandler>saveHandlerMap = null;
+       private boolean aggregating = false;
+       private CyNetwork network;
+
        static AttributeHandlingType[] stringArray = 
{AttributeHandlingType.MCV, AttributeHandlingType.CSV, 
                                                      
AttributeHandlingType.TSV, AttributeHandlingType.NONE};
 
@@ -143,6 +144,21 @@
                }
        }
 
+       
/**************************************************************************
+        * Instance methods for AttributeManager                                
  *
+        
*************************************************************************/
+       public AttributeManager () {
+       }
+
+       public AttributeManager (AttributeManager source) {
+               this.handlerMap = source.handlerMap;
+               this.saveHandlerMap = source.saveHandlerMap;
+               this.aggregating = source.aggregating;
+               for (int index = 0; index < 15; index++)
+                       this.defaultHandling[index] = 
source.defaultHandling[index];
+       }
+       
+
        /**
         * Add a new handler to our internal map for aggregating the designated
         * attribute and handlerType
@@ -150,7 +166,7 @@
         * @param attribute the attribute this handler is for
         * @param handlerType the aggregation method for use by the handler
         */
-       static public void addHandler(String attribute, AttributeHandlingType 
handlerType) {
+       public void addHandler(String attribute, AttributeHandlingType 
handlerType) {
                if (handlerMap == null) handlerMap = new HashMap();
 
                if (handlerMap.containsKey(attribute)) {
@@ -173,7 +189,7 @@
         *
         * @param attribute the attribute this handler is for
         */
-       static public void removeHandler(String attribute) {
+       public void removeHandler(String attribute) {
                if (handlerMap != null && handlerMap.containsKey(attribute)) {
                        handlerMap.remove(attribute);
                }
@@ -182,7 +198,7 @@
        /**
         * Save the current attribute map
         */
-       static public void saveSettings() {
+       public void saveSettings() {
                if (handlerMap == null) return;
                saveHandlerMap = new HashMap();
                for (String attribute: handlerMap.keySet()) {
@@ -194,7 +210,7 @@
        /**
         * Revert the attribute map back to the saved settings.
         */
-       static public void revertSettings() {
+       public void revertSettings() {
                handlerMap = saveHandlerMap;
                saveHandlerMap = null;
        }
@@ -202,7 +218,7 @@
        /**
         * Clear the attribute handler map
         */
-       static public void clearSettings() {
+       public void clearSettings() {
                handlerMap = null;
                saveHandlerMap = null;
        }
@@ -214,7 +230,7 @@
         * @return the AttributeHandler or null if there is no attribute handler
         *         for this attribute.
         */
-       static public AttributeHandler getHandler(String attribute) {
+       public AttributeHandler getHandler(String attribute) {
                if (handlerMap == null) return null;
                if (handlerMap.containsKey(attribute))
                        return handlerMap.get(attribute);
@@ -227,9 +243,9 @@
         *
         * @param network the CyNetwork we're going to read our options from
         */
-       static public void loadHandlerMappings(CyNetwork network) {
+       public void loadHandlerMappings(CyNetwork network) {
                CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
-               AttributeManager.network = network;
+               this.network = network;
                if (networkAttributes.hasAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE)) {
                        Map<String,String> attrMap = 
(Map<String,String>)networkAttributes.getMapAttribute(network.getIdentifier(), 
OVERRIDE_ATTRIBUTE);
                        for (String attr: attrMap.keySet()) {
@@ -243,7 +259,7 @@
         *
         * @param enable if 'true' enable aggregation otherwise, disable 
aggregation
         */
-       static public void setEnable(boolean enable) {
+       public void setEnable(boolean enable) {
                aggregating = enable;
        }
 
@@ -252,16 +268,16 @@
         *
         * @return 'true' if attribute aggregation is enabled otherwise, 'false'
         */
-       static public boolean getEnable() {
+       public boolean getEnable() {
                return aggregating;
        }
 
-       static public void setDefault(byte attributeType, AttributeHandlingType 
type) {
+       public void setDefault(byte attributeType, AttributeHandlingType type) {
                if (attributeType < 0) attributeType += 10;
                defaultHandling[attributeType] = type;
        }
 
-       static public AttributeHandler getDefaultHandler(byte attributeType, 
String attribute) {
+       public AttributeHandler getDefaultHandler(byte attributeType, String 
attribute) {
                AttributeHandlingType t;
                if (attributeType < 0) attributeType += 10;
                t = defaultHandling[attributeType];
@@ -276,7 +292,7 @@
        }
 
 
-       static public AttributeHandlingType stringToType(String str) {
+       public AttributeHandlingType stringToType(String str) {
                for (AttributeHandlingType type: 
AttributeHandlingType.values()) {
                        if (str.equals(type.toString()))
                                return type;
@@ -291,7 +307,7 @@
         *
         * @param mNode the metanode we're agregating over
         */
-       static public void updateAttributes(MetaNode mNode) {
+       public void updateAttributes(MetaNode mNode) {
                CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
                CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
                CyGroup metaGroup = mNode.getCyGroup();
@@ -311,16 +327,16 @@
                                // Yes, do it
                                if (MetaNodeManager.getMetaNode(node) != null) {
                                        // This is a metanode -- some algorithm 
(e.g. median) require recursion...
-                                       aggregateAttributes(nodeAttributes, 
"node", node.getIdentifier(), 
+                                       aggregateAttributes(nodeAttributes, 
node.getIdentifier(), 
                                                            
MetaNodeManager.getMetaNode(node));
                                } else {
-                                       aggregateAttributes(nodeAttributes, 
"node", node.getIdentifier(), null);
+                                       aggregateAttributes(nodeAttributes, 
node.getIdentifier(), null);
                                }
                        }
                }
                if (getEnable()) {
                        // Update all of the node attributes
-                       assignAttributes(nodeAttributes, "node", metaNodeName);
+                       assignAttributes(nodeAttributes, metaNodeName);
                }
 
                // Update our special attributes
@@ -338,9 +354,8 @@
         * @param source the source (node or edge ID) for the attributes
         * @param recurse a metanode if we are supposed to recurse (only done 
for MEDIAN)
         */
-       private static void aggregateAttributes(CyAttributes attrMap, 
-                                               String attrType,
-                                               String source, MetaNode 
recurse) {
+       private void aggregateAttributes(CyAttributes attrMap, 
+                                        String source, MetaNode recurse) {
                String [] attributes = attrMap.getAttributeNames();
                for (int i = 0; i < attributes.length; i++) {
                        String attr = attributes[i];
@@ -353,12 +368,13 @@
                        }
 
                        // Do we have a specific handler (override)?
-                       AttributeHandler handler = 
getHandler(attrType+"."+attr);
+                       // AttributeHandler handler = 
getHandler(attrType+"."+attr);
+                       AttributeHandler handler = getHandler(attr);
                        if (handler == null) {
                                // No, create a basic handler
-                               handler = 
getDefaultHandler(attrMap.getType(attr), attrType+"."+attr);
-                       }
-                       if (handler != null) {
+                               handler = 
getDefaultHandler(attrMap.getType(attr), attr);
+                               aggregateAttribute(attrMap, handler, source, 
recurse);
+                       } else {
                                // Aggregate
                                aggregateAttribute(attrMap, handler, source, 
recurse);
                        }
@@ -373,10 +389,10 @@
         * @param source the source (node or edge ID) for the attributes
         * @param recurse a metanode if we are supposed to recurse (only done 
for MEDIAN)
         */
-       private static void aggregateAttribute(CyAttributes attrMap,
-                                              AttributeHandler handler,
-                                              String source,
-                                              MetaNode recurse) {
+       private void aggregateAttribute(CyAttributes attrMap,
+                                       AttributeHandler handler,
+                                       String source,
+                                       MetaNode recurse) {
 
                if (recurse == null) {
                        Object value = handler.aggregateAttribute(attrMap, 
source, 1);
@@ -408,15 +424,15 @@
         * @param attrType "edge" or "node"
         * @param target the name of the object
         */
-       private static void     assignAttributes(CyAttributes attrMap,
-                                            String attrType,
-                                            String target) {
+       private void    assignAttributes(CyAttributes attrMap,
+                                      String target) {
 
                String [] attributes = attrMap.getAttributeNames();
                for (int i = 0; i < attributes.length; i++) {
                        String attr = attributes[i];
                        // Get our handler
-                       AttributeHandler handler = 
getHandler(attrType+"."+attr);
+                       // AttributeHandler handler = 
getHandler(attrType+"."+attr);
+                       AttributeHandler handler = getHandler(attr);
                        if (handler != null)
                                handler.assignAttribute(attrMap, target);
                }

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-05-21 05:13:01 UTC (rev 25507)
@@ -62,6 +62,7 @@
 
 // our imports
 import metaNodePlugin2.MetaNodePlugin2;
+import metaNodePlugin2.data.AttributeManager;
 import metaNodePlugin2.view.ViewUtils;
 
 // import csplugins.layout.Profile;
@@ -81,7 +82,7 @@
        private CyLogger logger = null;
        private CyGroup metaGroup = null;
 
-       private boolean aggregateAttributes = false;
+       private AttributeManager attributeManager = null;
        private boolean hideMetanode = true;
        private double metanodeOpacity = 0.;
        private boolean useNestedNetworks = false;
@@ -112,6 +113,8 @@
 
        public CyGroup getCyGroup() { return metaGroup; }
 
+       public CyNode getGroupNode() { return metaGroup.getGroupNode(); }
+
        /**
         * Add a node to this metaNode.  It will already have been added to the 
         * group, but we need to update our internal data structures and 
(possibly)
@@ -197,6 +200,10 @@
                // Restore our meta-edges
                ViewUtils.restoreEdges(metaGroup, metaEdges.values(), view);
 
+               // Update our attributes (if we're aggregating)
+               if (attributeManager != null)
+                       attributeManager.updateAttributes(this);
+
                collapsed = true;
        }
 
@@ -373,6 +380,11 @@
                this.nodeChartAttribute = nodeChartAttribute;
        }
 
+       /**
+        * Gets the attribute to use node charting
+        *
+        * @return the attribute to use for node charting
+        */
        public String getNodeChartAttribute() {
                return this.nodeChartAttribute;
        }
@@ -386,6 +398,11 @@
                this.chartType = chartType;
        }
 
+       /**
+        * Get the chart type we're using
+        *
+        * @return chart type
+        */
        public String getChartType() {
                return this.chartType;
        }
@@ -401,20 +418,26 @@
        }
 
        /**
-        * Controls whether this metanode is aggregating attributes
+        * Set the attribute manager (for attribute aggregation) that
+        * we're supposed to use.
         *
-        * @param aggregate if 'true' aggregate
+        * @param attributeManager the attribute manager to use
         */
-       public void setAggregateAttributes(boolean aggregate) {
-               if (!this.aggregateAttributes && aggregate) {
-                       this.aggregateAttributes = aggregate;
-                       // updateAttributes();
-               } else {
-                       this.aggregateAttributes = aggregate;
-               }
+       public void setAttributeManager(AttributeManager attributeManager) {
+               this.attributeManager = attributeManager;
        }
 
        /**
+        * Get the attribute manager (for attribute aggregation) that
+        * we're using.
+        *
+        * @return the attribute manager we're using
+        */
+       public AttributeManager getAttributeManager() {
+               return attributeManager;
+       }
+
+       /**
         * Returns 'true' if we hide the metnode when we expand the
         * network.
         *
@@ -475,6 +498,7 @@
         *              add a meta-edge to the parter
         *              if the partner is a group and the group is in our 
network:
         *                      add ourselves to the group's outer edges list 
(recursively)
+        *                      add ourselves to the partner's meta edge list
         *              if the partner is in a group:
         *                      add ourselves to the group's meta edge list
         */
@@ -494,7 +518,7 @@
                        CyEdge metaEdge = createMetaEdge(edge.getIdentifier(), 
metaGroup.getGroupNode(), node);
 
                        MetaNode metaPartner = 
MetaNodeManager.getMetaNode(node);
-                       if (metaPartner != null) { 
+                       if (metaPartner != null && 
metaPartner.metaGroup.getNetwork().equals(metaGroup.getNetwork())) { 
                                // Recursively add links to the appropriate 
children
                                addPartnerEdges(metaPartner);
                                metaPartner.addMetaEdge(metaEdge);

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-05-21 05:13:01 UTC (rev 25507)
@@ -44,6 +44,7 @@
 import cytoscape.view.CyNetworkView;
 
 import metaNodePlugin2.MetaNodePlugin2;
+import metaNodePlugin2.data.AttributeManager;
 
 
 /**
@@ -60,6 +61,7 @@
        protected static boolean useNestedNetworksDefault = false;
        protected static String chartTypeDefault = null;
        protected static String nodeChartAttributeDefault = null;
+       protected static AttributeManager defaultAttributeManager = new 
AttributeManager();
 
        public static final String X_HINT_ATTR = "__metanodeHintX";
        public static final String Y_HINT_ATTR = "__metanodeHintY";
@@ -92,6 +94,7 @@
                mn.setMetaNodeOpacity(metanodeOpacityDefault);
                mn.setChartType(chartTypeDefault);
                mn.setNodeChartAttribute(nodeChartAttributeDefault);
+               mn.setAttributeManager(new 
AttributeManager(defaultAttributeManager));
                if (metaGroup.getNetwork() == null) {
                        metaGroup.setNetwork(Cytoscape.getCurrentNetwork(), 
false);
                }
@@ -282,4 +285,13 @@
        static public String getChartTypeDefault() {
                return MetaNodeManager.chartTypeDefault;
        }
+
+       /**
+        * Gets the default attribute manager
+        *
+        * @return the default attribute manager object
+        */
+       static public AttributeManager getDefaultAttributeManager () {
+               return MetaNodeManager.defaultAttributeManager;
+       }
 }

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-05-21 05:13:01 UTC (rev 25507)
@@ -106,6 +106,7 @@
        private String chartType = null;
        private String nodeChartAttribute = null;
        private MetaNodeGroupViewer groupViewer = null;
+       private AttributeManager defaultAttributeManager = null;
 
        // Dialog components
        JPanel tunablePanel = null;
@@ -120,9 +121,11 @@
                metanodeProperties = new MetanodeProperties("metanode");
                this.groupViewer = viewer;
 
+               defaultAttributeManager = 
MetaNodeManager.getDefaultAttributeManager();
+
                initializeProperties();
 
-               AttributeManager.saveSettings();
+               defaultAttributeManager.saveSettings();
 
                initialize();
                pack();
@@ -248,7 +251,7 @@
                        nodeChartEnablers.add(t);
 
                        {
-                               // Get the attribute to map
+                               // Get the attribute to map (This should be a 
list! -- FIXME)
                                nodeChartAttrList = new 
Tunable("nodeChartAttribute", "Attribute to use for node chart",
                                                                Tunable.LIST, 
new Integer(0),
                                                                
getNodeAttributes(), null, 0);
@@ -343,7 +346,7 @@
                Tunable t = metanodeProperties.get("enableHandling");
                if ((t != null) && (t.valueChanged() || force)) {
       enableHandling = ((Boolean) t.getValue()).booleanValue();
-                       AttributeManager.setEnable(enableHandling);
+                       defaultAttributeManager.setEnable(enableHandling);
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                        enableTunables(enableHandling);
                }
@@ -387,27 +390,27 @@
                // For each default value, get the default and set it
                t = metanodeProperties.get("stringDefaults");
                if ((t != null) && (t.valueChanged() || force)) {
-                       AttributeManager.setDefault(CyAttributes.TYPE_STRING, 
(AttributeHandlingType)getListValue(t));
+                       
defaultAttributeManager.setDefault(CyAttributes.TYPE_STRING, 
(AttributeHandlingType)getListValue(t));
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
                t = metanodeProperties.get("intDefaults");
                if ((t != null) && (t.valueChanged() || force)) {
-                       AttributeManager.setDefault(CyAttributes.TYPE_INTEGER, 
(AttributeHandlingType)getListValue(t));
+                       
defaultAttributeManager.setDefault(CyAttributes.TYPE_INTEGER, 
(AttributeHandlingType)getListValue(t));
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
                t = metanodeProperties.get("doubleDefaults");
                if ((t != null) && (t.valueChanged() || force)) {
-                       AttributeManager.setDefault(CyAttributes.TYPE_FLOATING, 
(AttributeHandlingType)getListValue(t));
+                       
defaultAttributeManager.setDefault(CyAttributes.TYPE_FLOATING, 
(AttributeHandlingType)getListValue(t));
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
                t = metanodeProperties.get("listDefaults");
                if ((t != null) && (t.valueChanged() || force)) {
-                       
AttributeManager.setDefault(CyAttributes.TYPE_SIMPLE_LIST, 
(AttributeHandlingType)getListValue(t));
+                       
defaultAttributeManager.setDefault(CyAttributes.TYPE_SIMPLE_LIST, 
(AttributeHandlingType)getListValue(t));
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
                t = metanodeProperties.get("booleanDefaults");
                if ((t != null) && (t.valueChanged() || force)) {
-                       AttributeManager.setDefault(CyAttributes.TYPE_BOOLEAN, 
(AttributeHandlingType)getListValue(t));
+                       
defaultAttributeManager.setDefault(CyAttributes.TYPE_BOOLEAN, 
(AttributeHandlingType)getListValue(t));
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
        }
@@ -417,7 +420,7 @@
         */
        public void revertSettings() {
                metanodeProperties.revertProperties();
-               AttributeManager.revertSettings();
+               defaultAttributeManager.revertSettings();
        }
 
        /**
@@ -435,7 +438,7 @@
         * @param network the network we're updating our override values for
         */
        public void updateOverrides(CyNetwork network) {
-               AttributeManager.loadHandlerMappings(network);
+               defaultAttributeManager.loadHandlerMappings(network);
        }
 
        /**
@@ -489,11 +492,12 @@
         */
        private String[] getAttributes() {
                CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
-               CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
+               // CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
 
                List<String> attributeList = new ArrayList();
-               makeAttributes("node", nodeAttributes, attributeList);
-               makeAttributes("edge", edgeAttributes, attributeList);
+               makeAttributes(null, nodeAttributes, attributeList);
+               // makeAttributes("node", nodeAttributes, attributeList);
+               // makeAttributes("edge", edgeAttributes, attributeList);
                String [] a = new String[1];
                attributeArray = attributeList.toArray(a);
                Arrays.sort(attributeArray);
@@ -554,7 +558,7 @@
                        revertSettings();
                        setVisible(false);
                } else if (command.equals("clear")) {
-                       AttributeManager.clearSettings();
+                       defaultAttributeManager.clearSettings();
                        tunableChanged(attrList);
 
                // Apply the current settings to the selected metanodes
@@ -592,11 +596,11 @@
                mn.setUseNestedNetworks(useNestedNetworks);
                // mn.setSizeToBoundingBox(sizeToBoundingBox);
                mn.setHideMetaNode(hideMetaNode);
-               mn.setAggregateAttributes(enableHandling);
                // System.out.println("setting opacity for "+mn+" to 
"+metanodeOpacity);
                mn.setMetaNodeOpacity(metanodeOpacity);
                mn.setChartType(chartType);
                mn.setNodeChartAttribute(nodeChartAttribute);
+               mn.setAttributeManager(defaultAttributeManager);
        }
 
        public void tunableChanged(Tunable t) {
@@ -611,7 +615,7 @@
                        
MetaNodeManager.setExpandedOpacityDefault(metanodeOpacity);
                } else if (t.getName().equals("enableHandling")) {
       enableHandling = ((Boolean) t.getValue()).booleanValue();
-                       AttributeManager.setEnable(enableHandling);
+                       defaultAttributeManager.setEnable(enableHandling);
                        enableTunables(enableHandling);
                } else if (t.getName().equals("nodeChartAttribute")) {
                        nodeChartAttribute = (String)getListValue(t);
@@ -632,7 +636,7 @@
                        AttributeHandlingType handlerType = 
(AttributeHandlingType)getListValue(t);
 
                        // Create the handler
-                       AttributeManager.addHandler(attributeWP, handlerType);
+                       
defaultAttributeManager.addHandler(attributeWP.substring(5), handlerType);
                }
                repaint();
        }
@@ -640,16 +644,10 @@
        private void updateAttributeHandlers(String attributeWP) {
                CyAttributes attrs = null;
 
-               // Strip prefix
-               String attribute = attributeWP.substring(5);
+               attrs = Cytoscape.getNodeAttributes();
 
-               if (attributeWP.startsWith("edge"))
-                       attrs = Cytoscape.getEdgeAttributes();
-               else
-                       attrs = Cytoscape.getNodeAttributes();
+               byte type = attrs.getType(attributeWP);
 
-               byte type = attrs.getType(attribute);
-
                // Get the list
                AttributeHandlingType[] hTypes = 
AttributeManager.getHandlingOptions(type);
                AttributeHandlingType[] handlingTypes = new 
AttributeHandlingType[hTypes.length+1];
@@ -667,7 +665,7 @@
                typeList.setLowerBound(handlingTypes);
 
                // Do we already have a handler?
-               AttributeHandler handler = 
AttributeManager.getHandler(attributeWP);
+               AttributeHandler handler = 
defaultAttributeManager.getHandler(attributeWP);
                if (handler != null) {
                        // Yes, show the right one to the user
                        for (int i = 0; i < handlingTypes.length; i++) {

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
        2011-05-20 03:41:57 UTC (rev 25506)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
        2011-05-21 05:13:01 UTC (rev 25507)
@@ -60,7 +60,7 @@
                // Move the nodes around
                Dimension boundingBox = ViewUtils.restoreNodes(group, nn, 
nnView, position, Cytoscape.getNodeAttributes(), null);
 
-               System.out.println("Bounding box for "+group.toString()+" is 
"+boundingBox.getWidth()+"x"+boundingBox.getHeight());
+               // System.out.println("Bounding box for "+group.toString()+" is 
"+boundingBox.getWidth()+"x"+boundingBox.getHeight());
 
                // Add it to the network map as a child of the group's network
                CyNetwork network = group.getNetwork();

-- 
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