Author: scooter
Date: 2011-08-04 19:02:26 -0700 (Thu, 04 Aug 2011)
New Revision: 26382

Modified:
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodePlugin2.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/ViewUtils.java
Log:
Make sure to update settings from session files


Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodePlugin2.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodePlugin2.java
       2011-08-05 02:01:17 UTC (rev 26381)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodePlugin2.java
       2011-08-05 02:02:26 UTC (rev 26382)
@@ -147,6 +147,9 @@
                        Cytoscape.getPropertyChangeSupport()
                                  .addPropertyChangeListener( 
Cytoscape.CYTOSCAPE_INITIALIZED, this);
 
+                       Cytoscape.getPropertyChangeSupport()
+                                 .addPropertyChangeListener( 
Cytoscape.SESSION_LOADED, this);
+
                        // Add our context menu
                        
Cytoscape.getCurrentNetworkView().addNodeContextMenuListener(this);
                        
Cytoscape.getCurrentNetworkView().addGraphViewChangeListener(this);
@@ -188,7 +191,10 @@
                        // Handle interaction with other plugins
                        groupViewer.registerWithGroupPanel();
                        groupViewer.haveNodeCharts();
+                       groupViewer.getSettingsDialog().reloadSettings();
                        groupViewer.getSettingsDialog().updateNodeChartTypes();
+               } else if (e.getPropertyName() == Cytoscape.SESSION_LOADED) {
+                       groupViewer.getSettingsDialog().reloadSettings();
                }
        }
 

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-08-05 02:01:17 UTC (rev 26381)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
        2011-08-05 02:02:26 UTC (rev 26382)
@@ -85,6 +85,7 @@
 
        private AttributeManager attributeManager = null;
        private boolean hideMetanode = true;
+       private boolean dontExpandEmpty = true;
        private double metanodeOpacity = 0.;
        private boolean useNestedNetworks = false;
        private String nodeChartAttribute = null;
@@ -220,6 +221,9 @@
                if (!isCollapsed())
                        return;
 
+               if (dontExpandEmpty && metaGroup.getNodes().size() == 0)
+                       return;
+
                // Handle the case where we're hidden by a collapsed parent
                if (isHidden()) {
                        expandParent(view);
@@ -368,6 +372,15 @@
        }
 
        /**
+        * Sets whether or not we should expand empty metanodes.
+        *
+        * @param dontExpandEmpty if 'true' we will use nested networks
+        */
+       public void setDontExpandEmpty(boolean dontExpandEmpty) {
+               this.dontExpandEmpty = dontExpandEmpty;
+       }
+
+       /**
         * Sets the metanode opacity
         *
         * @param opacity the metanode opacity
@@ -517,10 +530,10 @@
                while(iterator.hasNext()) {
                        CyEdge edge = iterator.next();
                        CyNode node = getPartner(edge);
-                       // logger.debug("Outer edge = "+edge.getIdentifier());
+                       logger.debug("Outer edge = "+edge.getIdentifier());
 
                        if (ignoreMetaEdges && isMeta(edge)) {
-                               // logger.debug("...ignoring");
+                               logger.debug("...ignoring");
                                addMetaEdge(edge);
                                continue;
                        }
@@ -531,7 +544,6 @@
                        if (edge.getSource() == groupNode || edge.getTarget() 
== groupNode)
                                continue;
 
-
                        // Create the meta-edge to the external node, but 
maintain the directionality of the
                        // original edge
                        CyEdge metaEdge = null;

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-08-05 02:01:17 UTC (rev 26381)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
 2011-08-05 02:02:26 UTC (rev 26382)
@@ -60,6 +60,7 @@
        protected static boolean hideMetanodeDefault = true;
        protected static double metanodeOpacityDefault = 255.;
        protected static boolean useNestedNetworksDefault = false;
+       protected static boolean dontExpandEmptyDefault = true;
        protected static String chartTypeDefault = null;
        protected static String nodeChartAttributeDefault = null;
        protected static AttributeManager defaultAttributeManager = new 
AttributeManager();
@@ -113,6 +114,7 @@
 
                metaMap.put(metaGroup.getGroupNode(), mn);
                mn.setUseNestedNetworks(useNestedNetworksDefault);
+               mn.setDontExpandEmpty(dontExpandEmptyDefault);
                mn.setHideMetaNode(hideMetanodeDefault);
                mn.setMetaNodeOpacity(metanodeOpacityDefault);
                mn.setChartType(chartTypeDefault);
@@ -258,11 +260,9 @@
        }
 
        /**
-        * Sets whether or not we size the metnode to the bounding box
-        * of all of the children when we expand the network.  NOTE:
-        * this only makes sense if hideMetanode is false.
+        * Sets whether or not we use the nested network viewer
         *
-        * @param useNestedNetworks if 'true' we use nexted networks when we 
collapse
+        * @param useNestedNetworks if 'true' we use nested networks when we 
collapse
         */
        static public void setUseNestedNetworksDefault(boolean 
useNestedNetworks) {
                MetaNodeManager.useNestedNetworksDefault = useNestedNetworks;
@@ -279,6 +279,24 @@
        }
 
        /**
+        * Sets whether or not we expand empty metanodes
+        *
+        * @param dontExpandEmpty if 'true' we won't expand empty metanodes
+        */
+       static public void setDontExpandEmptyDefault(boolean dontExpandEmpty) {
+               MetaNodeManager.dontExpandEmptyDefault = dontExpandEmpty;
+       }
+
+       /**
+        * Returns 'true' if we don't expand empty metanodes.
+        *
+        * @return 'true' if we don't expand empty metanodes.
+        */
+       static public boolean getDontExpandEmptyDefault() {
+               return MetaNodeManager.dontExpandEmptyDefault;
+       }
+
+       /**
         * Sets the attribute to use for node charting.
         *
         * @param nodeChartAttribute the attribute to use for node charts

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-08-05 02:01:17 UTC (rev 26381)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/ui/MetanodeSettingsDialog.java
     2011-08-05 02:02:26 UTC (rev 26382)
@@ -56,6 +56,7 @@
 import cytoscape.groups.CyGroupViewer;
 import cytoscape.layout.Tunable;
 import cytoscape.layout.TunableListener;
+import cytoscape.logger.CyLogger;
 import cytoscape.visual.VisualPropertyDependency;
 import cytoscape.visual.VisualStyle;
 
@@ -100,6 +101,7 @@
        private List<Tunable>tunableEnablers = null;
        private List<Tunable>nodeChartEnablers = null;
        private boolean hideMetaNode = true;
+       private boolean dontExpandEmpty = true;
   private boolean enableHandling = false;
   private boolean useNestedNetworks = false;
        private double metanodeOpacity = 255.0f;
@@ -208,7 +210,7 @@
 
                
                metanodeProperties.add(new Tunable("appearanceGroup", "Metanode 
Appearance",
-                                                  Tunable.GROUP, new 
Integer(2),
+                                                  Tunable.GROUP, new 
Integer(4),
                                                   new Boolean(true), null, 
Tunable.COLLAPSABLE));
                {
                        {
@@ -219,6 +221,22 @@
                                metanodeProperties.add(t);
                        }
 
+                       {
+                               Tunable t = new Tunable("hideMetaNodes",
+                                                       "Hide metanodes when 
expanded",
+                                                       Tunable.BOOLEAN, new 
Boolean(true), 0);
+                               t.addTunableValueListener(this);
+                               metanodeProperties.add(t);
+                       }
+
+                       {
+                               Tunable t = new Tunable("dontExpandEmpty",
+                                                       "Don't expand empty 
metanodes",
+                                                       Tunable.BOOLEAN, new 
Boolean(true), 0);
+                               t.addTunableValueListener(this);
+                               metanodeProperties.add(t);
+                       }
+
                        // Sliders always look better when grouped
                        metanodeProperties.add(new Tunable("opacityGroup", 
"Metanode Opacity",
                                                          Tunable.GROUP, new 
Integer(1),
@@ -306,9 +324,6 @@
                        tunableEnablers.add(t);
                }
 
-               // We only really care about the property settings for our 
defaults
-               metanodeProperties.initializeProperties();
-
                metanodeProperties.add(new Tunable("attributesGroup",
                                                    "Overrides for Specific 
Attributes",
                                                    Tunable.GROUP, new 
Integer(3),
@@ -336,6 +351,8 @@
                        // Update
                        tunableChanged(attrList);
                }
+
+               reloadSettings();
                updateSettings(true);
        }
 
@@ -358,6 +375,13 @@
                        metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
                }
 
+               t = metanodeProperties.get("dontExpandEmpty");
+               if ((t != null) && (t.valueChanged() || force)) {
+      dontExpandEmpty = ((Boolean) t.getValue()).booleanValue();
+                       MetaNodeManager.setHideMetaNodeDefault(dontExpandEmpty);
+                       metanodeProperties.setProperty(t.getName(), 
t.getValue().toString());
+               }
+
                t = metanodeProperties.get("useNestedNetworks");
                if ((t != null) && (t.valueChanged() || force)) {
       useNestedNetworks = ((Boolean) t.getValue()).booleanValue();
@@ -433,6 +457,17 @@
        }
 
        /**
+        * Reload our properties (used when a new session is loaded)
+        */
+       public void reloadSettings() {
+               try {
+                       metanodeProperties.initializeProperties();
+               } catch (Exception e) {
+                       CyLogger.getLogger("metaNodePlugin").warning("Exception 
when initializing properties: '"+e.getMessage()+"' -- continuing");
+               }
+       }
+
+       /**
         * Update all of our attribute manager override values
         *
         * @param network the network we're updating our override values for
@@ -598,6 +633,7 @@
 
        public void updateMetaNodeSettings(MetaNode mn) {
                mn.setUseNestedNetworks(useNestedNetworks);
+               mn.setDontExpandEmpty(dontExpandEmpty);
                // mn.setSizeToBoundingBox(sizeToBoundingBox);
                mn.setHideMetaNode(hideMetaNode);
                // System.out.println("setting opacity for "+mn+" to 
"+metanodeOpacity);
@@ -611,6 +647,9 @@
                if (t.getName().equals("hideMetanodes")) {
       hideMetaNode = ((Boolean) t.getValue()).booleanValue();
                        MetaNodeManager.setHideMetaNodeDefault(hideMetaNode);
+               } else if (t.getName().equals("dontExpandEmpty")) {
+      dontExpandEmpty = ((Boolean) t.getValue()).booleanValue();
+                       
MetaNodeManager.setDontExpandEmptyDefault(dontExpandEmpty);
                } else if (t.getName().equals("useNestedNetworks")) {
       useNestedNetworks = ((Boolean) t.getValue()).booleanValue();
                        
MetaNodeManager.setUseNestedNetworksDefault(useNestedNetworks);

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
        2011-08-05 02:01:17 UTC (rev 26381)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
        2011-08-05 02:02:26 UTC (rev 26382)
@@ -258,11 +258,13 @@
         * @param view the CyNetworkView
         */
        public static void hideEdges(CyGroup metaGroup, 
Collection<CyEdge>edgeList, CyNetworkView view) {
+               /*
                CyNetwork network = metaGroup.getNetwork();
                for (CyEdge edge: edgeList) {
                        if (network.containsEdge(edge))
                                network.hideEdge(edge);
                }
+               */
        }
 
        /**

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