Author: paperwing
Date: 2012-02-03 13:31:18 -0800 (Fri, 03 Feb 2012)
New Revision: 28192

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/VisualPropertyKeeper.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindEdgeView.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNodeView.java
Log:
refs #633 Individual values of visual properties for View<CyNode> and 
View<CyEdge> objects are no longer stored individually. They now return the 
default value as set by VizMapper unless they were given an explicit value. 
Giving the View object an explicit value allows a way to set a "bypass" value 
that is not affected by VizMapper's settings. VizMapper changes should now show 
up in all the previews and rendering windows. Work remains to be done to give 
the visual property preview the proper zoom.

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
 2012-02-03 20:37:13 UTC (rev 28191)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
 2012-02-03 21:31:18 UTC (rev 28192)
@@ -61,10 +61,10 @@
                }
        }
        
-       // Override selected values from VisualProperties
-       private void updateDefaultValues() {
-               modifyDefaultValue(RichVisualLexicon.NODE_FILL_COLOR, new 
Color(120, 120, 120));
-       }
+//     // Override selected values from VisualProperties
+//     private void updateDefaultValues() {
+//             modifyDefaultValue(RichVisualLexicon.NODE_FILL_COLOR, new 
Color(120, 120, 120));
+//     }
        
 //     @Override
 //     public <T, V extends T> void setViewDefault(VisualProperty<? extends T> 
visualProperty,
@@ -82,23 +82,46 @@
                }
        }
        
-       public void initializeNode(VisualPropertyKeeper<CyNode> keeper) {
-               for (Entry<String, VisualPropertyValueHolder<?>> entry: 
nodeDefaultValues.entrySet()) { 
-                       keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
+       /**
+        * Obtain the default value stored for a given visual property.
+        * 
+        * @param <T> The type of the visual property's value
+        * @param visualProperty The visual property to look for a default 
value with
+        * @return The default value of the visual property
+        */
+       public <T> T getDefaultValue(VisualProperty<T> visualProperty) {
+               Class<?> targetDataType = visualProperty.getTargetDataType();
+               
+               if (defaultValueSets.get(targetDataType) != null) {
+                       VisualPropertyValueHolder<T> valueHolder = 
+                               (VisualPropertyValueHolder<T>)
+                               
defaultValueSets.get(targetDataType).get(visualProperty.getIdString());
+               
+                       if (valueHolder != null) {
+                               return valueHolder.getValue();
+                       }
                }
+               
+               return null;
        }
        
-       public void initializeEdge(VisualPropertyKeeper<CyEdge> keeper) {
-               for (Entry<String, VisualPropertyValueHolder<?>> entry: 
edgeDefaultValues.entrySet()) { 
-                       keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
-               }
-       }
-       
-       public void initializeNetwork(VisualPropertyKeeper<CyNetwork> keeper) {
-               for (Entry<String, VisualPropertyValueHolder<?>> entry: 
networkDefaultValues.entrySet()) {      
-                       keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
-               }
-       }
+//     public void initializeNode(VisualPropertyKeeper<CyNode> keeper) {
+//             for (Entry<String, VisualPropertyValueHolder<?>> entry: 
nodeDefaultValues.entrySet()) { 
+//                     keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
+//             }
+//     }
+//     
+//     public void initializeEdge(VisualPropertyKeeper<CyEdge> keeper) {
+//             for (Entry<String, VisualPropertyValueHolder<?>> entry: 
edgeDefaultValues.entrySet()) { 
+//                     keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
+//             }
+//     }
+//     
+//     public void initializeNetwork(VisualPropertyKeeper<CyNetwork> keeper) {
+//             for (Entry<String, VisualPropertyValueHolder<?>> entry: 
networkDefaultValues.entrySet()) {      
+//                     keeper.setVisualProperty(entry.getKey(), 
entry.getValue().getValue());
+//             }
+//     }
 }
 
 

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/VisualPropertyKeeper.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/VisualPropertyKeeper.java
      2012-02-03 20:37:13 UTC (rev 28191)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/VisualPropertyKeeper.java
      2012-02-03 21:31:18 UTC (rev 28192)
@@ -10,7 +10,7 @@
 // value amongst the VisualProperty objects
 public abstract class VisualPropertyKeeper<S> implements View<S>{
        private Map<String, VisualPropertyValueHolder<?>> valueHolders;
-       
+               
        public VisualPropertyKeeper() {
                valueHolders = new HashMap<String, 
VisualPropertyValueHolder<?>>();
        }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindEdgeView.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindEdgeView.java
      2012-02-03 20:37:13 UTC (rev 28191)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindEdgeView.java
      2012-02-03 21:31:18 UTC (rev 28192)
@@ -3,6 +3,7 @@
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
+import org.cytoscape.model.SUIDFactory;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualProperty;
 
@@ -10,10 +11,14 @@
 
        private CyEdge edge;
        private Long suid;
+       private DefaultValueVault defaultValueVault;
        
-       public WindEdgeView(CyEdge edge, Long suid) {
+       public WindEdgeView(DefaultValueVault defaultValueVault, 
+                       CyEdge edge) {
+               
                this.edge = edge;
-               this.suid = suid;               
+               this.suid = SUIDFactory.getNextSUID();  
+               this.defaultValueVault = defaultValueVault;
        }
        
        @Override
@@ -25,4 +30,17 @@
        public CyEdge getModel() {
                return edge;
        }
+       
+       @Override
+       public <T> T getVisualProperty(VisualProperty<T> visualProperty) {
+               T value = super.getVisualProperty(visualProperty);
+               
+               if (value != null) {
+                       // If we were given an explicit value, return it
+                       return value;
+               } else {
+                       // Otherwise, return the default value
+                       return 
defaultValueVault.getDefaultValue(visualProperty);
+               }
+       }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   2012-02-03 20:37:13 UTC (rev 28191)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   2012-02-03 21:31:18 UTC (rev 28192)
@@ -59,21 +59,18 @@
                
                WindNodeView nodeView;
                for (CyNode node : network.getNodeList()) {
-                       nodeView = new WindNodeView(node, 
SUIDFactory.getNextSUID());
-                       defaultValues.initializeNode(nodeView);
+                       nodeView = new WindNodeView(defaultValues, node);
                        
                        nodeViews.put(node.getIndex(), nodeView);
                }
                
                WindEdgeView edgeView;
                for (CyEdge edge : network.getEdgeList()) {
-                       edgeView = new WindEdgeView(edge, 
SUIDFactory.getNextSUID());
-                       defaultValues.initializeEdge(edgeView);
+                       edgeView = new WindEdgeView(defaultValues, edge);
                        
                        edgeViews.put(edge.getIndex(), edgeView);
                }
                
-               defaultValues.initializeNetwork(this);
        }
        
        @Override
@@ -169,7 +166,7 @@
                matchEdges();
                
                // Match the current network view to the currently applied 
visual style
-               updateToMatchVisualStyle();
+//             updateToMatchVisualStyle();
        }
        
        // Checks if there is a discrepancy between number of nodes and 
nodeViews, attempts
@@ -186,8 +183,7 @@
                                // Found a node without a view?
                                if (nodeViews.get(node.getIndex()) == null) {
                                        
-                                       WindNodeView nodeView = new 
WindNodeView(node, SUIDFactory.getNextSUID());
-                                       defaultValues.initializeNode(nodeView);
+                                       WindNodeView nodeView = new 
WindNodeView(defaultValues, node);
                                        
                                        nodeViews.put(node.getIndex(), 
nodeView);
                                        
@@ -232,8 +228,7 @@
                                // Found a edge without a view?
                                if (edgeViews.get(edge.getIndex()) == null) {
                                        
-                                       WindEdgeView edgeView = new 
WindEdgeView(edge, SUIDFactory.getNextSUID());
-                                       defaultValues.initializeEdge(edgeView);
+                                       WindEdgeView edgeView = new 
WindEdgeView(defaultValues, edge);
                                        
                                        edgeViews.put(edge.getIndex(), 
edgeView);
                                        
@@ -302,6 +297,19 @@
                defaultValues.modifyDefaultValue(visualProperty, defaultValue);
        }
 
+       @Override
+       public <T> T getVisualProperty(VisualProperty<T> visualProperty) {
+               T value = super.getVisualProperty(visualProperty);
+               
+               if (value != null) {
+                       // If we were given an explicit value, return it
+                       return value;
+               } else {
+                       // Otherwise, return the default value
+                       return defaultValues.getDefaultValue(visualProperty);
+               }
+       }
+       
 //     @Override
 //     public void handleEvent(AboutToRemoveNodesEvent e) {
 //             if (e.getSource() == network) {

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNodeView.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNodeView.java
      2012-02-03 20:37:13 UTC (rev 28191)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNodeView.java
      2012-02-03 21:31:18 UTC (rev 28192)
@@ -3,6 +3,7 @@
 import java.util.HashMap;
 
 import org.cytoscape.model.CyNode;
+import org.cytoscape.model.SUIDFactory;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualProperty;
 
@@ -10,10 +11,13 @@
 
        private CyNode node;
        private Long suid;
+       private DefaultValueVault defaultValueVault;
        
-       public WindNodeView(CyNode node, Long suid) {
+       public WindNodeView(DefaultValueVault defaultValueVault, 
+                       CyNode node) {
                this.node = node;
-               this.suid = suid;               
+               this.suid = SUIDFactory.getNextSUID();
+               this.defaultValueVault = defaultValueVault;
        }
        
        @Override
@@ -26,4 +30,16 @@
                return node;
        }
 
+       @Override
+       public <T> T getVisualProperty(VisualProperty<T> visualProperty) {
+               T value = super.getVisualProperty(visualProperty);
+               
+               if (value != null) {
+                       // If we were given an explicit value, return it
+                       return value;
+               } else {
+                       // Otherwise, return the default value
+                       return 
defaultValueVault.getDefaultValue(visualProperty);
+               }
+       }
 }

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