Author: kono
Date: 2010-09-15 10:09:30 -0700 (Wed, 15 Sep 2010)
New Revision: 21860

Added:
   core3/viewmodel-impl/branches/vp-tree/
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/EdgeViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NodeViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/VisualLexiconManagerImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
Removed:
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/RootVisualLexiconImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
Modified:
   
core3/viewmodel-impl/branches/vp-tree/src/integration/java/org/cytoscape/view/ITViewModelImpl.java
   
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Visual Property Tree version of view model.

Copied: core3/viewmodel-impl/branches/vp-tree (from rev 21529, 
core3/viewmodel-impl/trunk)


Property changes on: core3/viewmodel-impl/branches/vp-tree
___________________________________________________________________
Name: svn:ignore
   + .settings
target
.classpath
.project
.springBeans
eclipse_config

Name: svn:mergeinfo
   + 

Modified: 
core3/viewmodel-impl/branches/vp-tree/src/integration/java/org/cytoscape/view/ITViewModelImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/integration/java/org/cytoscape/view/ITViewModelImpl.java
     2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/integration/java/org/cytoscape/view/ITViewModelImpl.java
  2010-09-15 17:09:30 UTC (rev 21860)
@@ -2,7 +2,7 @@
 
 import org.cytoscape.integration.AbstractIntegrationTester;
 import org.cytoscape.view.model.CyNetworkViewFactory;
-import org.cytoscape.view.model.RootVisualLexicon;
+import org.cytoscape.view.model.VisualLexiconManager;
 
 /**
  * Integration test for viewmodel-impl bundle.
@@ -23,9 +23,9 @@
                                        "org.cytoscape, viewmodel-api, 
1.0-SNAPSHOT",
                                        "org.cytoscape, viewmodel-impl, 
1.0-SNAPSHOT", }, 
                                new String[] {
-                                       "rootVisualLexicon", 
"cyNetworkViewFactory" }, 
+                                       "lexiconManager", 
"cyNetworkViewFactory" }, 
                                new Class[] {
-                                       RootVisualLexicon.class, 
CyNetworkViewFactory.class },
+                                       VisualLexiconManager.class, 
CyNetworkViewFactory.class },
                                new String[] { "org.cytoscape.view.model" }
                                );
        }

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/EdgeViewImpl.java
 (from rev 21591, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/EdgeViewImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/EdgeViewImpl.java
                             (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/EdgeViewImpl.java
     2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,29 @@
+package org.cytoscape.view.model.internal;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.EdgeViewChangeMicroListener;
+import org.cytoscape.view.model.VisualProperty;
+
+public class EdgeViewImpl extends ViewImpl<CyEdge> {
+
+       private final CyNetworkView parent;
+       
+       public EdgeViewImpl(CyEdge model, CyEventHelper cyEventHelper, 
CyNetworkView parent) {
+               super(model, cyEventHelper);
+               this.parent = parent;
+       }
+
+       @Override
+       public <T, V extends T> void setVisualProperty(
+                       VisualProperty<? extends T> vp, V value) {
+               if(value == null)
+                       this.visualProperties.remove(vp);
+               else
+                       this.visualProperties.put(vp, value);
+               
+               
cyEventHelper.getMicroListener(EdgeViewChangeMicroListener.class, 
parent).edgeVisualPropertySet(this, vp, value);
+       }
+
+}

Deleted: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
      2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
   2010-09-15 17:09:30 UTC (rev 21860)
@@ -1,41 +0,0 @@
-package org.cytoscape.view.model.internal;
-
-import java.util.Properties;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.service.util.CyServiceRegistrar;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.CyNetworkViewFactory;
-
-public class NetworkViewFactoryImpl implements CyNetworkViewFactory {
-
-       private final CyEventHelper eventHelper;
-       private final CyServiceRegistrar registrar;
-
-       /**
-        * For injection, use this constructor.
-        * 
-        * @param eventHelper
-        */
-       public NetworkViewFactoryImpl(final CyEventHelper eventHelper,
-                       CyServiceRegistrar registrar) {
-
-               if (eventHelper == null)
-                       throw new NullPointerException("CyEventHelper is null");
-               this.eventHelper = eventHelper;
-
-               if (registrar == null)
-                       throw new NullPointerException("CyServiceRegistrar is 
null");
-               this.registrar = registrar;
-       }
-
-
-       @Override
-       public CyNetworkView getNetworkView(final CyNetwork network) {
-               final CyNetworkView view = new NetworkViewImpl(network, 
eventHelper);
-               registrar.registerAllServices(view, new Properties());
-
-               return view;
-       }
-}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
 (from rev 21568, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
                           (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewFactoryImpl.java
   2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,42 @@
+package org.cytoscape.view.model.internal;
+
+import java.util.Properties;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.service.util.CyServiceRegistrar;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.CyNetworkViewFactory;
+
+public class NetworkViewFactoryImpl implements CyNetworkViewFactory {
+
+       private final CyEventHelper eventHelper;
+       private final CyServiceRegistrar registrar;
+
+       /**
+        * For injection, use this constructor.
+        * 
+        * @param eventHelper
+        */
+       public NetworkViewFactoryImpl(final CyEventHelper eventHelper,
+                       CyServiceRegistrar registrar) {
+
+               if (eventHelper == null)
+                       throw new NullPointerException("CyEventHelper is null");
+               this.eventHelper = eventHelper;
+
+               if (registrar == null)
+                       throw new NullPointerException("CyServiceRegistrar is 
null");
+               
+               this.registrar = registrar;
+       }
+
+
+       @Override
+       public CyNetworkView getNetworkView(final CyNetwork network) {
+               final CyNetworkView view = new NetworkViewImpl(network, 
eventHelper);
+               registrar.registerAllServices(view, new Properties());
+
+               return view;
+       }
+}

Deleted: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
     2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
  2010-09-15 17:09:30 UTC (rev 21860)
@@ -1,159 +0,0 @@
-package org.cytoscape.view.model.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.GraphObject;
-import org.cytoscape.model.events.AboutToRemoveEdgeEvent;
-import org.cytoscape.model.events.AboutToRemoveEdgeListener;
-import org.cytoscape.model.events.AboutToRemoveNodeEvent;
-import org.cytoscape.model.events.AboutToRemoveNodeListener;
-import org.cytoscape.model.events.AddedEdgeEvent;
-import org.cytoscape.model.events.AddedEdgeListener;
-import org.cytoscape.model.events.AddedNodeEvent;
-import org.cytoscape.model.events.AddedNodeListener;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.events.AddedEdgeViewEvent;
-import org.cytoscape.view.model.events.AddedNodeViewEvent;
-import org.cytoscape.view.model.events.NetworkViewChangedEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Row-oriented implementation of CyNetworkView model. This is a consolidated
- * view model representing a network.
- * 
- * @author kono
- * 
- */
-public class NetworkViewImpl extends ViewImpl<CyNetwork> implements 
CyNetworkView, AddedEdgeListener,
-               AddedNodeListener, AboutToRemoveEdgeListener, 
AboutToRemoveNodeListener {
-       
-       private static final Logger logger = 
LoggerFactory.getLogger(NetworkViewImpl.class);
-
-       private Map<CyNode, View<CyNode>> nodeViews;
-       private Map<CyEdge, View<CyEdge>> edgeViews;
-
-       
-       public NetworkViewImpl(final CyNetwork network, final CyEventHelper 
cyEventHelper) {
-               super(network, cyEventHelper);
-
-               nodeViews = new HashMap<CyNode, View<CyNode>>();
-               edgeViews = new HashMap<CyEdge, View<CyEdge>>();
-
-               for (final CyNode node : network.getNodeList())
-                       nodeViews.put(node, new ViewImpl<CyNode>(node, 
cyEventHelper));
-
-               for (CyEdge edge : network.getEdgeList())
-                       edgeViews.put(edge, new ViewImpl<CyEdge>(edge, 
cyEventHelper));
-               
-               logger.info("* Network View Created.  SUID = " + suid);
-       }
-
-
-       @Override
-       public View<CyNode> getNodeView(CyNode node) {
-               return this.nodeViews.get(node);
-       }
-
-       @Override
-       public Collection<View<CyNode>> getNodeViews() {
-               return this.nodeViews.values();
-       }
-
-       @Override
-       public View<CyEdge> getEdgeView(final CyEdge edge) {
-               return this.edgeViews.get(edge);
-       }
-
-       @Override
-       public Collection<View<CyEdge>> getEdgeViews() {
-               return this.edgeViews.values();
-       }
-
-       @Override
-       public Collection<View<? extends GraphObject>> getAllViews() {
-               final Set<View<? extends GraphObject>> views = new 
HashSet<View<? extends GraphObject>>();
-
-               views.addAll(nodeViews.values());
-               views.addAll(edgeViews.values());
-               views.add(this);
-
-               return views;
-       }
-
-       
-       // /// Event Handlers //////
-
-       @Override
-       public void handleEvent(AboutToRemoveNodeEvent e) {
-               if (model != e.getSource())
-                       return;
-
-               nodeViews.remove(e.getNode());
-       }
-
-       @Override
-       public void handleEvent(AboutToRemoveEdgeEvent e) {
-               if (model != e.getSource())
-                       return;
-
-               edgeViews.remove(e.getEdge());
-
-       }
-
-       
-       @Override
-       public void handleEvent(final AddedNodeEvent e) {
-               if (model != e.getSource()) {
-                       logger.error("Error adding node: wrong network! " + 
model.toString()
-                                       + " ~~ " + e.getSource().toString());
-                       return;
-               }
-
-               final CyNode node = e.getNode();
-               System.out.println(" Adding node to view: " + node.toString());
-               final View<CyNode> nv = new ViewImpl<CyNode>(node, 
cyEventHelper);
-               nodeViews.put(node, nv);
-               cyEventHelper.fireSynchronousEvent(new AddedNodeViewEvent(this, 
nv));
-       }
-
-       
-       @Override
-       public void handleEvent(final AddedEdgeEvent e) {
-               if (model != e.getSource()) {
-                       logger.error("Error adding edge: wrong network! " + 
model.toString()
-                                       + " ~~ " + e.getSource().toString());
-                       return;
-               }
-
-               final CyEdge edge = e.getEdge();
-               System.out.println(" Adding edge to view! " + edge.toString());
-               final View<CyEdge> ev = new ViewImpl<CyEdge>(edge, 
cyEventHelper);
-               edgeViews.put(edge, ev); // FIXME: View creation here and in
-                                                                       // 
initializer: should be in one place
-
-               cyEventHelper.fireSynchronousEvent(new AddedEdgeViewEvent(this, 
ev));
-       }
-       
-       
-       //// TODO: FIXME: The following methods will be removed!
-       public void fitContent() {
-               System.out.println("running dummy fitContent");
-       }
-       public void fitSelected() {
-               System.out.println("running dummy fitSelected");
-       }
-       public void updateView() {
-               cyEventHelper.fireAsynchronousEvent( new 
NetworkViewChangedEvent(NetworkViewImpl.this));
-       }
-
-}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
 (from rev 21859, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
                          (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
  2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,182 @@
+package org.cytoscape.view.model.internal;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.model.events.AboutToRemoveEdgeEvent;
+import org.cytoscape.model.events.AboutToRemoveEdgeListener;
+import org.cytoscape.model.events.AboutToRemoveNodeEvent;
+import org.cytoscape.model.events.AboutToRemoveNodeListener;
+import org.cytoscape.model.events.AddedEdgeEvent;
+import org.cytoscape.model.events.AddedEdgeListener;
+import org.cytoscape.model.events.AddedNodeEvent;
+import org.cytoscape.model.events.AddedNodeListener;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.NetworkViewChangeMicroListener;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.model.events.AddedEdgeViewEvent;
+import org.cytoscape.view.model.events.AddedNodeViewEvent;
+import org.cytoscape.view.model.events.FitContentEvent;
+import org.cytoscape.view.model.events.FitSelectedEvent;
+import org.cytoscape.view.model.events.NetworkViewChangedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Row-oriented implementation of CyNetworkView model. This is a consolidated
+ * view model representing a network.
+ * 
+ * @author kono
+ * 
+ */
+public class NetworkViewImpl extends ViewImpl<CyNetwork> implements 
CyNetworkView, AddedEdgeListener,
+               AddedNodeListener, AboutToRemoveEdgeListener, 
AboutToRemoveNodeListener {
+       
+       private static final Logger logger = 
LoggerFactory.getLogger(NetworkViewImpl.class);
+
+       private Map<CyNode, View<CyNode>> nodeViews;
+       private Map<CyEdge, View<CyEdge>> edgeViews;
+
+       
+       /**
+        * Create a new instance of a network view model.
+        * This constructor do NOT fire event for presentation layer.
+        * 
+        * @param network
+        * @param cyEventHelper
+        */
+       public NetworkViewImpl(final CyNetwork network, final CyEventHelper 
cyEventHelper) {
+               super(network, cyEventHelper);
+
+               nodeViews = new HashMap<CyNode, View<CyNode>>();
+               edgeViews = new HashMap<CyEdge, View<CyEdge>>();
+
+               for (final CyNode node : network.getNodeList())
+                       nodeViews.put(node, new NodeViewImpl(node, 
cyEventHelper, this));
+
+               for (CyEdge edge : network.getEdgeList())
+                       edgeViews.put(edge, new EdgeViewImpl(edge, 
cyEventHelper, this));
+               
+               logger.info("Network View Model Created.  Model ID = " + 
this.getModel().getSUID() + ", View Model ID = " + suid + " First phase of 
network creation process (model creation) is done. \n\n");
+       }
+
+
+       @Override
+       public View<CyNode> getNodeView(CyNode node) {
+               return this.nodeViews.get(node);
+       }
+
+       @Override
+       public Collection<View<CyNode>> getNodeViews() {
+               return this.nodeViews.values();
+       }
+
+       @Override
+       public View<CyEdge> getEdgeView(final CyEdge edge) {
+               return this.edgeViews.get(edge);
+       }
+
+       @Override
+       public Collection<View<CyEdge>> getEdgeViews() {
+               return this.edgeViews.values();
+       }
+
+       @Override
+       public Collection<View<? extends CyTableEntry>> getAllViews() {
+               final Set<View<? extends CyTableEntry>> views = new 
HashSet<View<? extends CyTableEntry>>();
+
+               views.addAll(nodeViews.values());
+               views.addAll(edgeViews.values());
+               views.add(this);
+
+               return views;
+       }
+
+       
+       // /// Event Handlers //////
+
+       @Override
+       public void handleEvent(AboutToRemoveNodeEvent e) {
+               if (model != e.getSource())
+                       return;
+
+               nodeViews.remove(e.getNode());
+       }
+
+       @Override
+       public void handleEvent(AboutToRemoveEdgeEvent e) {
+               if (model != e.getSource())
+                       return;
+
+               edgeViews.remove(e.getEdge());
+       }
+
+       
+       @Override
+       public void handleEvent(final AddedNodeEvent e) {
+               // Respond to the event only if the source is equal to the 
network model associated with this view.
+               if (model != e.getSource())
+                       return;
+
+               final CyNode node = e.getNode();
+               logger.debug("Creating new node view model: " + 
node.toString());
+               final View<CyNode> nv = new NodeViewImpl(node, cyEventHelper, 
this);
+               nodeViews.put(node, nv);
+               
+               // Cascading event.
+               cyEventHelper.fireSynchronousEvent(new AddedNodeViewEvent(this, 
nv));
+       }
+
+       
+       @Override
+       public void handleEvent(final AddedEdgeEvent e) {
+               if (model != e.getSource())
+                       return;
+
+               final CyEdge edge = e.getEdge();
+               final View<CyEdge> ev = new EdgeViewImpl(edge, cyEventHelper, 
this);
+               edgeViews.put(edge, ev); // FIXME: View creation here and in
+                                                                       // 
initializer: should be in one place
+
+               cyEventHelper.fireSynchronousEvent(new AddedEdgeViewEvent(this, 
ev));
+       }
+       
+       // The following methods are utilities for calling methods in upper 
layer (presentation)
+       
+       public void fitContent() {
+               logger.debug("Firing fitContent event from: View ID = " + 
this.suid);
+               cyEventHelper.fireAsynchronousEvent( new FitContentEvent(this));
+       }
+       
+       public void fitSelected() {
+               logger.debug("Firing fitSelected event from: View ID = " + 
this.suid);
+               cyEventHelper.fireAsynchronousEvent( new 
FitSelectedEvent(this));
+       }
+       
+       public void updateView() {
+               logger.debug("Firing update view event from: View ID = " + 
this.suid);
+               cyEventHelper.fireSynchronousEvent( new 
NetworkViewChangedEvent(this));
+       }
+
+
+       @Override
+       public <T, V extends T> void setVisualProperty(
+                       VisualProperty<? extends T> vp, V value) {
+               if(value == null)
+                       this.visualProperties.remove(vp);
+               else
+                       this.visualProperties.put(vp, value);
+               
+               
cyEventHelper.getMicroListener(NetworkViewChangeMicroListener.class, 
this).networkVisualPropertySet(this, vp, value);   
+       }
+       
+}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NodeViewImpl.java
 (from rev 21591, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NodeViewImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NodeViewImpl.java
                             (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/NodeViewImpl.java
     2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,30 @@
+package org.cytoscape.view.model.internal;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.NodeViewChangeMicroListener;
+import org.cytoscape.view.model.VisualProperty;
+
+public class NodeViewImpl extends ViewImpl<CyNode> {
+
+       private final CyNetworkView parent;
+       
+       public NodeViewImpl(CyNode model, CyEventHelper cyEventHelper, 
CyNetworkView parent) {
+               super(model, cyEventHelper);
+               this.parent = parent;
+       }
+       
+       @Override
+       public <T, V extends T> void setVisualProperty(
+                       VisualProperty<? extends T> vp, V value) {
+               
+               if(value == null)
+                       this.visualProperties.remove(vp);
+               else
+                       this.visualProperties.put(vp, value);
+               
+               
cyEventHelper.getMicroListener(NodeViewChangeMicroListener.class, 
parent).nodeVisualPropertySet(this, vp, value);
+       }
+
+}

Deleted: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/RootVisualLexiconImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/RootVisualLexiconImpl.java
       2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/RootVisualLexiconImpl.java
    2010-09-15 17:09:30 UTC (rev 21860)
@@ -1,147 +0,0 @@
-package org.cytoscape.view.model.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.RootVisualLexicon;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.VisualLexicon;
-import org.cytoscape.view.model.VisualProperty;
-
-public class RootVisualLexiconImpl implements RootVisualLexicon {
-
-       private final Map<String, VisualLexicon> lexiconMap;
-       private final Map<String, VisualProperty<?>> vpMap;
-
-       /**
-        * Constructor. Just initializes collections for currently available
-        * renderers and VPs
-        */
-       public RootVisualLexiconImpl() {
-               lexiconMap = new HashMap<String, VisualLexicon>();
-               vpMap = new HashMap<String, VisualProperty<?>>();
-       }
-
-       /**
-        * DOCUMENT ME!
-        * 
-        * @param serializableName
-        *            DOCUMENT ME!
-        * 
-        * @return DOCUMENT ME!
-        */
-       public VisualProperty<?> getVisualProperty(final String id) {
-               return vpMap.get(id);
-       }
-
-       /* return collection of only those that have a matching objectType */
-       private Set<VisualProperty<?>> filterForObjectType(
-                       final Collection<VisualProperty<?>> vps, final String 
objectType) {
-
-               final Set<VisualProperty<?>> result = new 
HashSet<VisualProperty<?>>();
-
-               for (VisualProperty<?> vp : vps) {
-                       if (vp.getObjectType().equals(objectType))
-                               result.add(vp);
-               }
-
-               return result;
-       }
-
-       public VisualLexicon getVisualLexicon(String lexiconName) {
-               return lexiconMap.get(lexiconName);
-       }
-
-       @SuppressWarnings("unchecked")
-       public void addVisualLexicon(VisualLexicon lexicon, Map props) {
-               final String presentationName = lexicon.toString();
-
-               // If it already exists, replace it by the new one.
-               if (lexiconMap.containsKey(presentationName))
-                       lexiconMap.remove(presentationName);
-
-               // Add the new lexicon to the map.
-               lexiconMap.put(presentationName, lexicon);
-
-               // Update set of VisualProperties
-               Set<VisualProperty<?>> vps = lexicon.getAllVisualProperties();
-               for (VisualProperty<?> vp : vps)
-                       this.vpMap.put(vp.getIdString(), vp);
-       }
-
-       @SuppressWarnings("unchecked")
-       public void removeVisualLexicon(VisualLexicon lexicon, Map props) {
-               final String presentationName = lexicon.toString();
-               
-
-               this.lexiconMap.remove(presentationName);
-       }
-
-       public Collection<VisualLexicon> getAllVisualLexicons() {
-               return this.lexiconMap.values();
-       }
-
-       public Set<VisualProperty<?>> getAllVisualProperties() {
-               return new HashSet<VisualProperty<?>>(vpMap.values());
-       }
-
-       /**
-        * Returns the collection of all those VisualProperties that are in use 
for
-        * the given GraphObjects. I.e. these are the VisualProperties, for 
which
-        * setting a value will actually change the displayed graph.
-        * 
-        * Note: returns the same as collectionOfVisualProperties() if both 
args are
-        * null.
-        * 
-        * @param views
-        *            DOCUMENT ME!
-        * @param objectType
-        *            DOCUMENT ME!
-        * @return VisualProperties
-        */
-       public Set<VisualProperty<?>> getVisualProperties(
-                       Collection<? extends View<?>> views, String objectType) 
{
-
-               if (views == null)
-                       return filterForObjectType(vpMap.values(), objectType);
-
-               // System.out.println("making list of VisualProperties in 
use:");
-               final Set<VisualProperty<?>> toRemove = new 
HashSet<VisualProperty<?>>();
-
-
-               // System.out.println("removing:"+toRemove.size());
-               final Set<VisualProperty<?>> result = new 
HashSet<VisualProperty<?>>(
-                               vpMap.values());
-               result.removeAll(toRemove);
-
-               // System.out.println("len of result:"+result.size());
-               return filterForObjectType(result, objectType);
-       }
-
-       public Set<VisualProperty<?>> getVisualProperties(
-                       CyNetworkView networkview, String objectType) {
-               if (networkview != null) {
-                       // FIXME: could filter Views based on objectType, right 
here
-                       final Collection<View<?>> views = new 
HashSet<View<?>>(networkview
-                                       .getNodeViews());
-                       views.addAll(networkview.getEdgeViews());
-
-                       return getVisualProperties(views, objectType);
-               } else {
-                       return filterForObjectType(vpMap.values(), objectType);
-               }
-       }
-
-       public Collection<VisualProperty<?>> getVisualProperties(String 
objectType) {
-               return filterForObjectType(vpMap.values(), objectType);
-       }
-
-       public void addVisualProperty(VisualProperty<?> vp) {
-               this.vpMap.put(vp.getIdString(), vp);
-       }
-
-}

Deleted: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
    2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
 2010-09-15 17:09:30 UTC (rev 21860)
@@ -1,116 +0,0 @@
-package org.cytoscape.view.model.internal;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.model.SUIDFactory;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.ViewChangeListener;
-import org.cytoscape.view.model.VisualProperty;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * This is an implementation of row-oriented ViewModel.
- * 
- * @author kono
- *
- * @param <M>
- */
-public class ViewImpl<M> implements View<M> {
-
-       private static final Logger logger = 
LoggerFactory.getLogger(ViewImpl.class);
-       
-       protected final M model;
-       protected final long suid;
-       
-       protected final CyEventHelper cyEventHelper;
-       
-       //TODO: Thread safety?
-       private final Map<VisualProperty<?>, Object> visualProperties;
-       private final Map<VisualProperty<?>, Object> visualPropertyLocks;
-       
-       
-       public ViewImpl(final M model, final CyEventHelper cyEventHelper) {
-               if(model == null)
-                       throw new IllegalArgumentException("Data model cannot 
be null.");
-               if(cyEventHelper == null)
-                       throw new IllegalArgumentException("CyEventHelper is 
null.");
-               
-               this.suid = SUIDFactory.getNextSUID();
-               this.model = model;
-               this.cyEventHelper = cyEventHelper;
-               
-               this.visualProperties = new HashMap<VisualProperty<?>, 
Object>();
-               this.visualPropertyLocks = new HashMap<VisualProperty<?>, 
Object>();
-               
-               logger.info("Graph Object View Created.  SUID = " + suid);
-       }
-
-       
-       @Override
-       public M getModel() {
-               return model;
-       }
-
-       
-       @Override
-       public long getSUID() {
-               return suid;
-       }
-       
-
-       @Override
-       public <T, V extends T> void setVisualProperty(
-                       VisualProperty<? extends T> vp, V value) {
-               
-               if(value == null)
-                       this.visualProperties.remove(vp);
-               else
-                       this.visualProperties.put(vp, value);
-               
-               final ViewChangeListener vcl = 
cyEventHelper.getMicroListener(ViewChangeListener.class, this);
-               if(vcl != null)
-                       vcl.visualPropertySet(vp, value);
-       }
-
-       
-       @SuppressWarnings("unchecked")
-       @Override
-       public <T> T getVisualProperty(VisualProperty<T> vp) {
-               
-               if(visualPropertyLocks.get(vp) == null) {
-                       if(visualProperties.get(vp) == null)
-                               return vp.getDefault();
-                       else
-                               return (T) visualProperties.get(vp);
-                       
-               } else
-                       return (T) this.visualPropertyLocks.get(vp);
-       }
-
-       
-       // TODO: should I fire event?
-       @Override
-       public <T, V extends T> void setLockedValue(VisualProperty<? extends T> 
vp,
-                       V value) {
-               this.visualPropertyLocks.put(vp, value);
-       }
-       
-
-       @Override
-       public boolean isValueLocked(VisualProperty<?> vp) {
-               if(visualPropertyLocks.get(vp) == null)
-                       return false;
-               else 
-                       return true;
-       }
-
-       @Override
-       public void clearValueLock(VisualProperty<?> vp) {
-               this.visualPropertyLocks.remove(vp);
-       }
-
-}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
 (from rev 21580, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
                         (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/ViewImpl.java
 2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,105 @@
+package org.cytoscape.view.model.internal;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.SUIDFactory;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.NodeViewChangeMicroListener;
+import org.cytoscape.view.model.VisualProperty;
+
+
+/**
+ * This is an implementation of row-oriented ViewModel.
+ * 
+ * @author kono
+ *
+ * @param <M>
+ */
+public abstract class ViewImpl<M> implements View<M> {
+       
+       protected final M model;
+       protected final long suid;
+       
+       protected final CyEventHelper cyEventHelper;
+       
+       //TODO: Thread safety?
+       protected final Map<VisualProperty<?>, Object> visualProperties;
+       protected final Map<VisualProperty<?>, Object> visualPropertyLocks;
+       
+       
+       /**
+        * Create an instance of view model, but not firing event to upper 
layer.
+        * 
+        * @param model
+        * @param cyEventHelper
+        */
+       public ViewImpl(final M model, final CyEventHelper cyEventHelper) {
+               if(model == null)
+                       throw new IllegalArgumentException("Data model cannot 
be null.");
+               if(cyEventHelper == null)
+                       throw new IllegalArgumentException("CyEventHelper is 
null.");
+               
+               this.suid = SUIDFactory.getNextSUID();
+               this.model = model;
+               this.cyEventHelper = cyEventHelper;
+               
+               this.visualProperties = new HashMap<VisualProperty<?>, 
Object>();
+               this.visualPropertyLocks = new HashMap<VisualProperty<?>, 
Object>();
+       }
+
+       
+       @Override
+       public M getModel() {
+               return model;
+       }
+
+       
+       @Override
+       public long getSUID() {
+               return suid;
+       }
+       
+
+       abstract public <T, V extends T> void setVisualProperty(
+                       VisualProperty<? extends T> vp, V value);
+
+       
+       @SuppressWarnings("unchecked")
+       @Override
+       public <T> T getVisualProperty(VisualProperty<T> vp) {
+               
+               if(visualPropertyLocks.get(vp) == null) {
+                       if(visualProperties.get(vp) == null)
+                               return vp.getDefault();
+                       else
+                               return (T) visualProperties.get(vp);
+                       
+               } else
+                       return (T) this.visualPropertyLocks.get(vp);
+       }
+
+       
+       // TODO: should I fire event?
+       @Override
+       public <T, V extends T> void setLockedValue(VisualProperty<? extends T> 
vp,
+                       V value) {
+               this.visualPropertyLocks.put(vp, value);
+       }
+       
+
+       @Override
+       public boolean isValueLocked(VisualProperty<?> vp) {
+               if(visualPropertyLocks.get(vp) == null)
+                       return false;
+               else 
+                       return true;
+       }
+
+       @Override
+       public void clearValueLock(VisualProperty<?> vp) {
+               this.visualPropertyLocks.remove(vp);
+       }
+
+}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/VisualLexiconManagerImpl.java
 (from rev 21529, 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/RootVisualLexiconImpl.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/VisualLexiconManagerImpl.java
                         (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/java/org/cytoscape/view/model/internal/VisualLexiconManagerImpl.java
 2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,47 @@
+package org.cytoscape.view.model.internal;
+
+import java.util.Map;
+
+import org.cytoscape.view.model.VisualLexiconManager;
+import org.cytoscape.view.model.VisualLexicon;
+
+public class VisualLexiconManagerImpl implements VisualLexiconManager {
+
+       // There is only one lexicon.
+       private final VisualLexicon lexicon;
+
+       /**
+        * Constructor. Just initializes collections for currently available
+        * renderers and VPs
+        */
+       public VisualLexiconManagerImpl(final VisualLexicon lexicon) {
+               if(lexicon == null)
+                       throw new NullPointerException("Visual Lexicon cannot 
be null.");
+               
+               this.lexicon = lexicon;
+       }
+       
+       
+       @Override
+       @SuppressWarnings("unchecked")
+       public void addVisualLexicon(VisualLexicon newLexicon, Map props) {
+               final String presentationName = lexicon.toString();
+
+               lexicon.mergeLexicon(newLexicon);
+       }
+
+       @Override
+       @SuppressWarnings("unchecked")
+       public void removeVisualLexicon(VisualLexicon lexicon, Map props) {
+               final String presentationName = lexicon.toString();
+               
+               // FIXME: need to remove actual props!
+       }
+
+
+       @Override
+       public VisualLexicon getLexicon() {
+               return lexicon;
+       }
+
+}

Modified: 
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
    2010-09-15 17:09:30 UTC (rev 21860)
@@ -18,8 +18,8 @@
                </osgi:service-properties>
        </osgi:service>
 
-       <osgi:service id="rootVisualLexiconService" ref="rootVisualLexicon"
-               interface="org.cytoscape.view.model.RootVisualLexicon">
+       <osgi:service id="visualLexiconManagerService" ref="lexiconManager"
+               interface="org.cytoscape.view.model.VisualLexiconManager">
                <osgi:service-properties>
                        <entry key="service.type" value="objectFacade" />
                </osgi:service-properties>
@@ -29,6 +29,6 @@
        <osgi:set id="renderers" 
interface="org.cytoscape.view.model.VisualLexicon"
                cardinality="0..N">
                <osgi:listener bind-method="addVisualLexicon"
-                       unbind-method="removeVisualLexicon" 
ref="rootVisualLexicon" />
+                       unbind-method="removeVisualLexicon" 
ref="lexiconManager" />
        </osgi:set>
 </beans>

Modified: 
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
    2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
 2010-09-15 17:09:30 UTC (rev 21860)
@@ -18,7 +18,12 @@
                <constructor-arg ref="cyServiceRegistrarRef" />
        </bean>
 
+
+       <bean id="minimalLexicon" 
class="org.cytoscape.view.model.internal.MinimalVisualLexicon" />
+       
        <!-- Catalog object of available VP. This will be exported as service. 
-->
-       <bean id="rootVisualLexicon" 
class="org.cytoscape.view.model.internal.RootVisualLexiconImpl" />
+       <bean id="lexiconManager" 
class="org.cytoscape.view.model.internal.VisualLexiconManagerImpl">
+               <constructor-arg ref="minimalLexicon" />
+       </bean>
        
 </beans>

Deleted: 
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
       2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
    2010-09-15 17:09:30 UTC (rev 21860)
@@ -1,49 +0,0 @@
-package org.cytoscape.view.model;
-
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertNotNull;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.event.DummyCyEventHelper;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.TestCyNetworkFactory;
-import org.cytoscape.view.model.AbstractViewTest;
-import org.cytoscape.view.model.internal.ViewImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class CyNodeViewTest extends AbstractViewTest<CyNode> {
-       
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               
-               final CyNetwork network = TestCyNetworkFactory.getInstance();
-               final CyNode node = network.addNode();
-               
-               final CyEventHelper mockHelper = new DummyCyEventHelper();
-               
-               view = new ViewImpl<CyNode>(node, mockHelper);
-               
-       }
-       
-
-       @After
-       public void tearDown() throws Exception {
-       }
-       
-       @Test
-    public void testGetModel() {
-               assertNotNull( view.getModel() );
-               
-               boolean modelTypeTest = false;
-               if(view.getModel() instanceof CyNode)
-                       modelTypeTest = true;
-               
-               assertTrue(modelTypeTest);
-               
-       }
-
-}

Copied: 
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
 (from rev 21591, 
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java)
===================================================================
--- 
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
                            (rev 0)
+++ 
core3/viewmodel-impl/branches/vp-tree/src/test/java/org/cytoscape/view/model/CyNodeViewTest.java
    2010-09-15 17:09:30 UTC (rev 21860)
@@ -0,0 +1,50 @@
+package org.cytoscape.view.model;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.event.DummyCyEventHelper;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.TestCyNetworkFactory;
+import org.cytoscape.view.model.AbstractViewTest;
+import org.cytoscape.view.model.internal.NodeViewImpl;
+import org.cytoscape.view.model.internal.ViewImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CyNodeViewTest extends AbstractViewTest<CyNode> {
+       
+       @Before
+       public void setUp() throws Exception {
+               super.setUp();
+               
+               final CyNetwork network = TestCyNetworkFactory.getInstance();
+               final CyNode node = network.addNode();
+               
+               final CyEventHelper mockHelper = new DummyCyEventHelper();
+               
+               view = new NodeViewImpl(node, mockHelper, null);
+               
+       }
+       
+
+       @After
+       public void tearDown() throws Exception {
+       }
+       
+       @Test
+    public void testGetModel() {
+               assertNotNull( view.getModel() );
+               
+               boolean modelTypeTest = false;
+               if(view.getModel() instanceof CyNode)
+                       modelTypeTest = true;
+               
+               assertTrue(modelTypeTest);
+               
+       }
+
+}

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