Author: rozagh
Date: 2012-05-01 17:51:44 -0700 (Tue, 01 May 2012)
New Revision: 29071

Modified:
   
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/GroupAttributesLayout.java
   
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutContext.java
   
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutTask.java
   
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutAlgorithm.java
   
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutContext.java
   
core3/impl/trunk/layout-impl/src/main/java/org/cytoscape/view/layout/internal/algorithms/GridNodeLayout.java
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/DynamicLayoutMenu.java
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
Log:
fixes #929 added an unweighted option for the attributes list of layouts (for 
both setting panel and layout menu) . Corrected layout context for Group layout 
and implemented missing getSupportSelectedOnly method for some of the layouts 
(based on 2.8.2).

Modified: 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/GroupAttributesLayout.java
===================================================================
--- 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/GroupAttributesLayout.java
    2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/GroupAttributesLayout.java
    2012-05-02 00:51:44 UTC (rev 29071)
@@ -88,4 +88,10 @@
        public GroupAttributesLayoutContext createLayoutContext() {
                return new GroupAttributesLayoutContext();
        }
+       
+       @Override
+       public boolean getSupportsSelectedOnly() {
+               return true;
+       }
+
 }

Modified: 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutContext.java
===================================================================
--- 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutContext.java
      2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutContext.java
      2012-05-02 00:51:44 UTC (rev 29071)
@@ -1,12 +1,11 @@
 package csapps.layout.algorithms.graphPartition;
 
-import org.cytoscape.model.CyNetwork;
 import org.cytoscape.work.Tunable;
 import org.cytoscape.work.TunableValidator;
 
 public class AttributeCircleLayoutContext  implements TunableValidator {
-       @Tunable(description = "The attribute to use for the layout")
-       public String attribute = CyNetwork.NAME;
+//     @Tunable(description = "The attribute to use for the layout")
+//     public String attribute = CyNetwork.NAME;
        
 //     @Tunable(description="Node attribute to be use")
 //     public ListSingleSelection<Integer> attrName;
@@ -19,7 +18,8 @@
 
        @Override
        public ValidationState getValidationState(final Appendable errMsg) {
-               return attribute.length() > 0 && spacing > 0.0 ? 
ValidationState.OK : ValidationState.INVALID;
+       //      return attribute.length() > 0 && spacing > 0.0 ? 
ValidationState.OK : ValidationState.INVALID;
+               return ValidationState.OK;
        }
 
        /**
@@ -27,10 +27,4 @@
         *
         * @param value the name of the attribute
         */
-       public void setLayoutAttribute(String value) {
-               if (value.equals("(none)"))
-                       this.attribute = null;
-               else
-                       this.attribute = value;
-       }
 }

Modified: 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutTask.java
===================================================================
--- 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutTask.java
 2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/AttributeCircleLayoutTask.java
 2012-05-02 00:51:44 UTC (rev 29071)
@@ -46,8 +46,8 @@
                int r = (int) Math.sqrt(count);
                r *= context.spacing;
 
-               if (context.attribute != null && count > 0) {
-                       final CyColumn column = 
nodes.get(0).getRow().getTable().getColumn(context.attribute);
+               if (layoutAttribute!= null && count > 0) {
+                       final CyColumn column = 
nodes.get(0).getRow().getTable().getColumn(layoutAttribute);
                        Class<?> klass = (column == null) ? null : 
column.getType();
                        if (klass != null && 
Comparable.class.isAssignableFrom(klass)){
                                // FIXME: I assume this would be better, but 
get type errors if I try:
@@ -82,8 +82,8 @@
                }
 
                public int compare(LayoutNode o1, LayoutNode o2) {
-                       T v1 = o1.getRow().get(context.attribute, klass);
-                       T v2 = o2.getRow().get(context.attribute, klass);
+                       T v1 = o1.getRow().get(layoutAttribute, klass);
+                       T v2 = o2.getRow().get(layoutAttribute, klass);
                        if (String.class.isAssignableFrom(klass)){ // i.e. if 
klass _is_ String.class
                                String s1 = String.class.cast(v1);
                                String s2 = String.class.cast(v2);

Modified: 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutAlgorithm.java
===================================================================
--- 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutAlgorithm.java
   2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutAlgorithm.java
   2012-05-02 00:51:44 UTC (rev 29071)
@@ -89,4 +89,10 @@
        public Object createLayoutContext() {
                return new HierarchicalLayoutContext();
        }
+       
+       @Override
+       public boolean getSupportsSelectedOnly() {
+               return true;
+       }
+
 }

Modified: 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutContext.java
===================================================================
--- 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutContext.java
     2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/hierarchicalLayout/HierarchicalLayoutContext.java
     2012-05-02 00:51:44 UTC (rev 29071)
@@ -18,8 +18,6 @@
        public int topEdge = 32;
        @Tunable(description="Right edge margin")
        public int rightMargin = 7000;
-       @Tunable(description="layout selected nodes only")
-       public boolean selected_only = false;
 
        @Override // TODO
        public ValidationState getValidationState(final Appendable errMsg) {

Modified: 
core3/impl/trunk/layout-impl/src/main/java/org/cytoscape/view/layout/internal/algorithms/GridNodeLayout.java
===================================================================
--- 
core3/impl/trunk/layout-impl/src/main/java/org/cytoscape/view/layout/internal/algorithms/GridNodeLayout.java
        2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/layout-impl/src/main/java/org/cytoscape/view/layout/internal/algorithms/GridNodeLayout.java
        2012-05-02 00:51:44 UTC (rev 29071)
@@ -63,4 +63,10 @@
        public Object createLayoutContext() {
                return new GridNodeLayoutContext();
        }
+       
+       @Override
+       public boolean getSupportsSelectedOnly() {
+               return true;
+       }
+
 }

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/DynamicLayoutMenu.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/DynamicLayoutMenu.java
       2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/DynamicLayoutMenu.java
       2012-05-02 00:51:44 UTC (rev 29071)
@@ -32,6 +32,7 @@
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.UnexpectedException;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -72,7 +73,9 @@
     private final CyNetwork network;
     private final CyApplicationManager appMgr;
 
+       private static final String UNWEIGHTED = "(none)";
 
+
     /**
      * Creates a new DynamicLayoutMenu object.
      *
@@ -125,7 +128,8 @@
     }
 
     private void addAttributeMenus(JMenu parent, CyTable attributes, 
Set<Class<?>> typeSet, boolean selectedOnly) {
-        for (final CyColumn column : attributes.getColumns())
+        parent.add(new LayoutAttributeMenuItem(UNWEIGHTED, selectedOnly));
+       for (final CyColumn column : attributes.getColumns())
             if (typeSet.contains(column.getType()))
                 parent.add(new LayoutAttributeMenuItem(column.getName(), 
selectedOnly));
     }
@@ -137,7 +141,7 @@
         if (usesNodeAttrs || usesEdgeAttrs) {
             allNodes = new JMenu("All Nodes");
             selNodes = new JMenu("Selected Nodes Only");
-
+            
             if (usesNodeAttrs) {
                 addNodeAttributeMenus((JMenu) allNodes, false);
                 addNodeAttributeMenus((JMenu) selNodes, true);
@@ -175,9 +179,11 @@
                     nodeViews = CyLayoutAlgorithm.ALL_NODE_VIEWS;
 
                 String layoutAttribute = null;
-                if (layout.getSupportedNodeAttributeTypes().size() > 0 || 
layout.getSupportedEdgeAttributeTypes().size() > 0)
-                    layoutAttribute = e.getActionCommand();
-
+                if (layout.getSupportedNodeAttributeTypes().size() > 0 || 
layout.getSupportedEdgeAttributeTypes().size() > 0){
+                       layoutAttribute = e.getActionCommand();
+                       if (layoutAttribute.equals(UNWEIGHTED))
+                               layoutAttribute = null;
+                }
                 
tm.execute(layout.createTaskIterator(netView,layout.getDefaultLayoutContext(),nodeViews,layoutAttribute));
             }
         }

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
    2012-05-02 00:26:50 UTC (rev 29070)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
    2012-05-02 00:51:44 UTC (rev 29071)
@@ -108,6 +108,8 @@
        private LayoutAttributeTunable layoutAttributeTunable;
        private JPanel layoutAttributePanel;
        private final SelectedTunable selectedTunable;
+       
+       private static final String UNWEIGHTED = "(none)";
 
        /**
         * Creates a new LayoutSettingsDialog object.
@@ -418,8 +420,8 @@
                                CyNetworkView view = 
appMgr.getCurrentNetworkView();
                                setNetworkView(view);
                                
-                               if (currentLayout.getSupportsSelectedOnly()) {
-                                       selectedTunable.selectedNodesOnly =  
hasSelectedNodes(view);
+                               if (currentLayout.getSupportsSelectedOnly() && 
hasSelectedNodes(view)) {
+                                       selectedTunable.selectedNodesOnly =  
true;
                                        JPanel panel = 
taskManager.getConfiguration(null, selectedTunable);
                                        algorithmPanel.add(panel, new 
GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.PAGE_START, 
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
                                }
@@ -445,6 +447,7 @@
                                panel.invalidate();
                        }
                }
+               
        }
 
        private boolean hasSelectedNodes(CyNetworkView view) {
@@ -476,6 +479,9 @@
                attributes.add(column.getName());
             }
                }
+               
+               if (attributes.size()>0)
+                       attributes.add(0, UNWEIGHTED);
         return attributes;
        }
        
@@ -483,6 +489,8 @@
                if (layoutAttributeTunable == null || 
layoutAttributeTunable.layoutAttribute == null) {
                        return null;
                }
+               
if(layoutAttributeTunable.layoutAttribute.getSelectedValue().equals(UNWEIGHTED))
+                       return null;
                return 
layoutAttributeTunable.layoutAttribute.getSelectedValue();
        }
 

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