Author: kono
Date: 2010-09-20 13:52:49 -0700 (Mon, 20 Sep 2010)
New Revision: 21955

Modified:
   
core3/presentation-api/branches/vp-tree/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
   
core3/presentation-api/branches/vp-tree/src/test/java/org/cytoscape/view/presentation/AbstractVisualLexiconTest.java
Log:
Texts are fixed.  To traverse tree, caller should check the node is in the 
lexicon or not.  Otherwise, the entire tree will be re-constructed.  

Modified: 
core3/presentation-api/branches/vp-tree/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
===================================================================
--- 
core3/presentation-api/branches/vp-tree/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
   2010-09-20 20:12:26 UTC (rev 21954)
+++ 
core3/presentation-api/branches/vp-tree/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
   2010-09-20 20:52:49 UTC (rev 21955)
@@ -47,9 +47,6 @@
        
        // Returns all visual properties as a set.
        public Set<VisualProperty<?>> getAllVisualProperties() {
-               System.out.println("Keys = " + 
visualPropertyMap.keySet().size());
-               System.out.println("Values = " + 
visualPropertyMap.values().size());
-               
                return new 
HashSet<VisualProperty<?>>(visualPropertyMap.values());
        }
        
@@ -110,4 +107,11 @@
                
                return children;
        }
+       
+       protected void addVisualProperty(final VisualProperty<?> vp) {
+               if(this.visualPropertyMap.containsKey(vp.getIdString()))
+                       throw new IllegalStateException("The key " + 
vp.getIdString() + " already exists in the lexicon.");
+               
+               this.visualPropertyMap.put(vp.getIdString(), vp);
+       }
 }

Modified: 
core3/presentation-api/branches/vp-tree/src/test/java/org/cytoscape/view/presentation/AbstractVisualLexiconTest.java
===================================================================
--- 
core3/presentation-api/branches/vp-tree/src/test/java/org/cytoscape/view/presentation/AbstractVisualLexiconTest.java
        2010-09-20 20:12:26 UTC (rev 21954)
+++ 
core3/presentation-api/branches/vp-tree/src/test/java/org/cytoscape/view/presentation/AbstractVisualLexiconTest.java
        2010-09-20 20:52:49 UTC (rev 21955)
@@ -29,18 +29,23 @@
        }
        
        
-       protected void testTree(VisualLexicon lextcon) throws Exception {
-               final VisualProperty<NullDataType> root = 
lextcon.getRootVisualProperty();
+       protected void testTree(VisualLexicon lexicon) throws Exception {
+               final VisualProperty<NullDataType> root = 
lexicon.getRootVisualProperty();
                assertNotNull(root);
-               assertEquals(lextcon.getRootVisualProperty(), root);
+               assertEquals(lexicon.getRootVisualProperty(), root);
                
-               Collection<VisualProperty<?>> firstChildren = 
root.getChildren();
+               Collection<VisualProperty<?>> firstChildren = new 
HashSet<VisualProperty<?>>();
+               for(VisualProperty<?> child:root.getChildren()) {
+                       if(lexicon.getAllVisualProperties().contains(child))
+                               firstChildren.add(child);
+               }
+               
                assertFalse(0 == firstChildren.size());
-               traverse(firstChildren);
+               traverse(firstChildren, lexicon);
        }
        
 
-       private void traverse(final Collection<VisualProperty<?>> vpSet) {
+       private void traverse(final Collection<VisualProperty<?>> vpSet, 
VisualLexicon lexicon) {
 
                Collection<VisualProperty<?>> children = vpSet;
                Collection<VisualProperty<?>> nextChildren = new 
HashSet<VisualProperty<?>>();
@@ -54,12 +59,15 @@
                        for (final VisualProperty<?> nextCh : 
child.getChildren())
                                assertEquals(child, nextCh.getParent());
 
-                       nextChildren.addAll(child.getChildren());
+                       for(VisualProperty<?> newChild:child.getChildren()) {
+                               
if(lexicon.getAllVisualProperties().contains(newChild))
+                                       nextChildren.add(newChild);
+                       }
                }
 
                if (nextChildren.size() == 0)
                        return;
                else
-                       traverse(nextChildren);
+                       traverse(nextChildren, lexicon);
        }
 }

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