Author: kono
Date: 2009-03-12 14:21:29 -0700 (Thu, 12 Mar 2009)
New Revision: 16242

Modified:
   core3/viewmodel-impl/trunk/osgi.bnd
   
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewFactoryImpl.java
   
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewImpl.java
   
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/VisualPropertyCatalogImpl.java
   
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Made all classes OSGi-dependent-API-free.

Modified: core3/viewmodel-impl/trunk/osgi.bnd
===================================================================
--- core3/viewmodel-impl/trunk/osgi.bnd 2009-03-12 20:27:51 UTC (rev 16241)
+++ core3/viewmodel-impl/trunk/osgi.bnd 2009-03-12 21:21:29 UTC (rev 16242)
@@ -2,6 +2,6 @@
 # Use this file to add customized Bnd instructions for the bundle
 #-----------------------------------------------------------------
 
-Spring-Context: META-INF/spring/*.xml
+Import-Package: *
 Private-Package: 
${bundle.namespace}.internal,${bundle.namespace}.events.internal
 

Modified: 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewFactoryImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewFactoryImpl.java
        2009-03-12 20:27:51 UTC (rev 16241)
+++ 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewFactoryImpl.java
        2009-03-12 21:21:29 UTC (rev 16242)
@@ -31,7 +31,7 @@
  You should have received a copy of the GNU Lesser General Public License
  along with this library; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
 package org.cytoscape.view.model.internal;
 
 import org.cytoscape.event.CyEventHelper;
@@ -41,83 +41,59 @@
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.CyNetworkViewFactory;
 
-import org.osgi.framework.BundleContext;
 
-
 /**
  *
  */
-public class ColumnOrientedNetworkViewFactoryImpl implements 
CyNetworkViewFactory {
+public class ColumnOrientedNetworkViewFactoryImpl implements
+               CyNetworkViewFactory {
        private CyEventHelper eventHelper;
-       private BundleContext bundleContext;
 
        /**
+        * For injection, use this constructor.
+        * 
+        * @param eventHelper
+        */
+       public ColumnOrientedNetworkViewFactoryImpl(CyEventHelper eventHelper) {
+               if (eventHelper == null)
+                       throw new NullPointerException("CyEventHelper is null");
+               this.eventHelper = eventHelper;
+       }
+
+       /**
         * For setter injection (hmm. whats that?)
         */
        public ColumnOrientedNetworkViewFactoryImpl() {
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param eventHelper DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param eventHelper
+        *            DOCUMENT ME!
         */
        public void setEventHelper(final CyEventHelper eventHelper) {
                this.eventHelper = eventHelper;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public CyEventHelper getEventHelper() {
                return this.eventHelper;
        }
 
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param bundleContext DOCUMENT ME!
-        */
-       public void setBundleContext(final BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param network
+        *            for which the CyNetworkView is to be created
+        * @return DOCUMENT ME!
         */
-       public BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-       /**
-        * Creates a new CyNetworkFactoryImpl object.
-        *
-        * @param eventHelper DOCUMENT ME!
-        * @param bundleContext DOCUMENT ME!
-        */
-       public ColumnOrientedNetworkViewFactoryImpl(final CyEventHelper 
eventHelper,
-                                                final BundleContext 
bundleContext) {
-               if (eventHelper == null)
-                       throw new NullPointerException("CyEventHelper is null");
-
-               if (bundleContext == null)
-                       throw new NullPointerException("bundleContext is null");
-
-               this.eventHelper = eventHelper;
-               this.bundleContext = bundleContext;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param network for which the CyNetworkView is to be created
-        * @return  DOCUMENT ME!
-        */
        public CyNetworkView getNetworkViewFor(final CyNetwork network) {
-               return new ColumnOrientedNetworkViewImpl(eventHelper, network, 
bundleContext);
+               return new ColumnOrientedNetworkViewImpl(eventHelper, network);
        }
 }

Modified: 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewImpl.java
       2009-03-12 20:27:51 UTC (rev 16241)
+++ 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/ColumnOrientedNetworkViewImpl.java
       2009-03-12 21:21:29 UTC (rev 16242)
@@ -31,11 +31,15 @@
  You should have received a copy of the GNU Lesser General Public License
  along with this library; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
 package org.cytoscape.view.model.internal;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
 import org.cytoscape.event.CyEventHelper;
-
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
@@ -48,7 +52,6 @@
 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.VisualProperty;
@@ -59,46 +62,41 @@
 import org.cytoscape.view.model.events.internal.SubsetCreatedEventImpl;
 import org.cytoscape.view.model.events.internal.SubsetDestroyedEventImpl;
 
-import org.osgi.framework.BundleContext;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-
 /**
  *
  */
-public class ColumnOrientedNetworkViewImpl implements CyNetworkView, 
AddedEdgeListener,
-                                                   AddedNodeListener, 
AboutToRemoveEdgeListener,
-                                                   AboutToRemoveNodeListener {
-       private BundleContext bc;
+public class ColumnOrientedNetworkViewImpl implements CyNetworkView,
+               AddedEdgeListener, AddedNodeListener, AboutToRemoveEdgeListener,
+               AboutToRemoveNodeListener {
+
        private CyEventHelper eventHelper;
        private CyNetwork network;
        private HashMap<CyNode, ColumnOrientedViewImpl<CyNode>> nodeViews;
        private HashMap<CyEdge, ColumnOrientedViewImpl<CyEdge>> edgeViews;
-       private HashMap<String, Set<View<?extends GraphObject>>> subsets;
+       private HashMap<String, Set<View<? extends GraphObject>>> subsets;
        private ColumnOrientedViewImpl<CyNetwork> networkView;
        private HashMap<VisualProperty<?>, ColumnOrientedViewColumn<?>> columns;
-       
+
        /**
         * Creates a new ColumnOrientedNetworkViewImpl object.
-        *
-        * @param eventHelper  DOCUMENT ME!
-        * @param network  DOCUMENT ME!
-        * @param bc  DOCUMENT ME!
+        * 
+        * @param eventHelper
+        *            DOCUMENT ME!
+        * @param network
+        *            DOCUMENT ME!
+        * @param bc
+        *            DOCUMENT ME!
         */
-       public ColumnOrientedNetworkViewImpl(final CyEventHelper eventHelper, 
final CyNetwork network,
-                                         final BundleContext bc) {
+       public ColumnOrientedNetworkViewImpl(final CyEventHelper eventHelper,
+                       final CyNetwork network) {
                this.eventHelper = eventHelper;
-               this.bc = bc;
                this.network = network;
+
                nodeViews = new HashMap<CyNode, 
ColumnOrientedViewImpl<CyNode>>();
                edgeViews = new HashMap<CyEdge, 
ColumnOrientedViewImpl<CyEdge>>();
-               subsets = new HashMap<String, Set<View<?extends 
GraphObject>>>();
+               subsets = new HashMap<String, Set<View<? extends 
GraphObject>>>();
                columns = new HashMap<VisualProperty<?>, 
ColumnOrientedViewColumn<?>>();
-               
+
                for (CyNode node : network.getNodeList()) {
                        nodeViews.put(node, new 
ColumnOrientedViewImpl<CyNode>(node, this));
                }
@@ -108,21 +106,13 @@
                }
 
                networkView = new ColumnOrientedViewImpl<CyNetwork>(network, 
this);
-
-               //  register event listeners:
-               bc.registerService(AddedEdgeListener.class.getName(), this, 
null);
-               bc.registerService(AddedNodeListener.class.getName(), this, 
null);
-               bc.registerService(AboutToRemoveEdgeListener.class.getName(), 
this, null);
-               bc.registerService(AboutToRemoveNodeListener.class.getName(), 
this, null);
-
-               // FIXME: how are we going to un-register?
        }
 
        /**
-        * Returns the network this view was created for.  The network is 
immutable for this
-        * view, so there is no way to set it.
-        *
-        * @return  DOCUMENT ME!
+        * Returns the network this view was created for. The network is 
immutable
+        * for this view, so there is no way to set it.
+        * 
+        * @return DOCUMENT ME!
         */
        public CyNetwork getNetwork() {
                return network;
@@ -130,10 +120,11 @@
 
        /**
         * Returns a View for a specified Node.
-        *
-        * @param n  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @param n
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public View<CyNode> getCyNodeView(final CyNode n) {
                return nodeViews.get(n);
@@ -141,8 +132,8 @@
 
        /**
         * Returns a list of Views for all CyNodes in the network.
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public List<View<CyNode>> getCyNodeViews() {
                return new ArrayList<View<CyNode>>(nodeViews.values());
@@ -150,10 +141,11 @@
 
        /**
         * Returns a View for a specified Edge.
-        *
-        * @param e  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @param e
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public View<CyEdge> getCyEdgeView(final CyEdge e) {
                return edgeViews.get(e);
@@ -161,8 +153,8 @@
 
        /**
         * Returns a list of Views for all CyEdges in the network.
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public List<View<CyEdge>> getCyEdgeViews() {
                return new ArrayList<View<CyEdge>>(edgeViews.values());
@@ -170,8 +162,8 @@
 
        /**
         * Returns the view for this Network.
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public View<CyNetwork> getNetworkView() {
                return networkView;
@@ -179,12 +171,12 @@
 
        /**
         * Returns a list of all View including those for Nodes, Edges, and 
Network.
-        *
-        * @return  DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
-       public List<View<?extends GraphObject>> getAllViews() {
-               final List<View<?extends GraphObject>> result = new 
ArrayList<View<?extends GraphObject>>(nodeViews
-                                                                               
                          .values());
+       public List<View<? extends GraphObject>> getAllViews() {
+               final List<View<? extends GraphObject>> result = new 
ArrayList<View<? extends GraphObject>>(
+                               nodeViews.values());
                result.addAll(edgeViews.values());
                result.add(networkView);
 
@@ -193,24 +185,37 @@
 
        /* Handle events in model and update accordingly: */
        /**
-        *  DOCUMENT ME!
-        *
-        * @param e DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param e
+        *            DOCUMENT ME!
         */
        public void handleEvent(final AddedEdgeEvent e) {
                if (network != e.getSource())
                        return;
 
                final CyEdge edge = e.getEdge();
-               edgeViews.put(edge, new ColumnOrientedViewImpl<CyEdge>(edge, 
this)); // FIXME: View creation here and in initializer: should be in one place
+               edgeViews.put(edge, new ColumnOrientedViewImpl<CyEdge>(edge, 
this)); // FIXME:
+                                                                               
                                                                                
// View
+                                                                               
                                                                                
// creation
+                                                                               
                                                                                
// here
+                                                                               
                                                                                
// and
+                                                                               
                                                                                
// in
+                                                                               
                                                                                
// initializer:
+                                                                               
                                                                                
// should
+                                                                               
                                                                                
// be
+                                                                               
                                                                                
// in
+                                                                               
                                                                                
// one
+                                                                               
                                                                                
// place
 
                // FIXME: fire events!
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param e DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param e
+        *            DOCUMENT ME!
         */
        public void handleEvent(final AddedNodeEvent e) {
                if (network != e.getSource())
@@ -221,9 +226,10 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param e DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param e
+        *            DOCUMENT ME!
         */
        public void handleEvent(final AboutToRemoveEdgeEvent e) {
                System.out.println("handling event: " + e);
@@ -235,9 +241,10 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param e DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param e
+        *            DOCUMENT ME!
         */
        public void handleEvent(final AboutToRemoveNodeEvent e) {
                if (network != e.getSource())
@@ -246,83 +253,98 @@
                edgeViews.remove(e.getNode());
        }
 
-       public <T> ColumnOrientedViewColumn<T> getColumn(final 
VisualProperty<T> vp){
+       public <T> ColumnOrientedViewColumn<T> getColumn(final 
VisualProperty<T> vp) {
                if (vp == null)
                        throw new NullPointerException("VisualProperty must not 
be null");
-               if (columns.containsKey(vp)){
+               if (columns.containsKey(vp)) {
                        return (ColumnOrientedViewColumn<T>) columns.get(vp);
                } else { // create column
-                       ColumnOrientedViewColumn<T> column = new 
ColumnOrientedViewColumn<T>(vp);
+                       ColumnOrientedViewColumn<T> column = new 
ColumnOrientedViewColumn<T>(
+                                       vp);
                        columns.put(vp, column);
                        return column;
                }
        }
-       
+
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
-       public Set<View<?extends GraphObject>> getSubset(final String name) {
+       public Set<View<? extends GraphObject>> getSubset(final String name) {
                return subsets.get(name);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
-        * @param subset DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
+        * @param subset
+        *            DOCUMENT ME!
         */
-       public void createSubset(final String name, final Set<View<?extends 
GraphObject>> subset) {
+       public void createSubset(final String name,
+                       final Set<View<? extends GraphObject>> subset) {
                subsets.put(name, subset);
-               eventHelper.fireSynchronousEvent(new 
SubsetCreatedEventImpl(this, name),
-                                                SubsetCreatedListener.class);
+               eventHelper.fireSynchronousEvent(
+                               new SubsetCreatedEventImpl(this, name),
+                               SubsetCreatedListener.class);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
-        * @param toAdd DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
+        * @param toAdd
+        *            DOCUMENT ME!
         */
-       public void addToSubset(final String name, final Set<View<?extends 
GraphObject>> toAdd) {
-               final Set<View<?extends GraphObject>> subset = 
subsets.get(name);
+       public void addToSubset(final String name,
+                       final Set<View<? extends GraphObject>> toAdd) {
+               final Set<View<? extends GraphObject>> subset = 
subsets.get(name);
 
                if (subset == null)
                        throw new NullPointerException("non-existent subset");
 
                subset.addAll(toAdd);
-               eventHelper.fireSynchronousEvent(new 
SubsetChangedEventImpl(this, name),
-                                                SubsetChangedListener.class);
+               eventHelper.fireSynchronousEvent(
+                               new SubsetChangedEventImpl(this, name),
+                               SubsetChangedListener.class);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
-        * @param toRemove DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
+        * @param toRemove
+        *            DOCUMENT ME!
         */
-       public void removeFromSubset(final String name, final Set<View<?extends 
GraphObject>> toRemove) {
-               final Set<View<?extends GraphObject>> subset = 
subsets.get(name);
+       public void removeFromSubset(final String name,
+                       final Set<View<? extends GraphObject>> toRemove) {
+               final Set<View<? extends GraphObject>> subset = 
subsets.get(name);
 
                if (subset == null)
                        throw new NullPointerException("non-existent subset");
 
                subset.removeAll(toRemove);
-               eventHelper.fireSynchronousEvent(new 
SubsetChangedEventImpl(this, name),
-                                                SubsetChangedListener.class);
+               eventHelper.fireSynchronousEvent(
+                               new SubsetChangedEventImpl(this, name),
+                               SubsetChangedListener.class);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
         */
        public void deleteSubset(final String name) {
                subsets.remove(name);
-               eventHelper.fireSynchronousEvent(new 
SubsetDestroyedEventImpl(this, name),
-                                                SubsetDestroyedListener.class);
+               eventHelper.fireSynchronousEvent(new 
SubsetDestroyedEventImpl(this,
+                               name), SubsetDestroyedListener.class);
        }
 }

Modified: 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/VisualPropertyCatalogImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/VisualPropertyCatalogImpl.java
   2009-03-12 20:27:51 UTC (rev 16241)
+++ 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/VisualPropertyCatalogImpl.java
   2009-03-12 21:21:29 UTC (rev 16242)
@@ -31,9 +31,15 @@
  You should have received a copy of the GNU Lesser General Public License
  along with this library; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
 package org.cytoscape.view.model.internal;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.DependentVisualPropertyCallback;
 import org.cytoscape.view.model.Renderer;
@@ -41,82 +47,54 @@
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.model.VisualPropertyCatalog;
 
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-
 /**
  * The singleton class that holds all currently defined VisualProperties.
  */
 public class VisualPropertyCatalogImpl implements VisualPropertyCatalog {
-       private BundleContext bundleContext;
 
+       // Map of visal properties. This object will be updated dynamically by
+       // listeners
+       private final Set<VisualProperty<?>> visalPropertySet;
+
        /**
-        * For setter injection (hmm. whats that?)
+        * Constructor. Just initializes collections for currently available
+        * renderers and VPs
         */
        public VisualPropertyCatalogImpl() {
+               visalPropertySet = new HashSet<VisualProperty<?>>();
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param bundleContext DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param renderer
+        *            DOCUMENT ME!
         */
-       public void setBundleContext(final BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-       /**
-        * Creates a new CyNetworkFactoryImpl object.
-        *
-        * @param h  DOCUMENT ME!
-        */
-       public VisualPropertyCatalogImpl(final BundleContext bundleContext) {
-               if (bundleContext == null)
-                       throw new NullPointerException("bundleContext is null");
-
-               this.bundleContext = bundleContext;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param renderer DOCUMENT ME!
-        */
        public void addVisualPropertiesOfRenderer(final Renderer renderer) {
                throw new RuntimeException("not applicable");
        }
 
-       /** Add a top-level VisualProperty. Note: this is most likely _not_ 
what you want to use.
-        * @param vp the VisualProperty to add
+       /**
+        * Add a top-level VisualProperty. Note: this is most likely _not_ what 
you
+        * want to use.
+        * 
+        * @param vp
+        *            the VisualProperty to add
         */
        public void addVisualProperty(final VisualProperty<?> vp) {
                throw new RuntimeException("not applicable");
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param name
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public VisualProperty<?> getVisualProperty(final String name) {
-               for (VisualProperty<?> vp : readAllVisualPropertiesFromOSGI()) {
+               for (VisualProperty<?> vp : visalPropertySet) {
                        if (vp.getID().equals(name)) {
                                return vp;
                        }
@@ -129,7 +107,7 @@
         * Returns the collection of all defined VisualProperties. Note that 
not all
         * of these will be actually in use. For showing in a UI, use of ... is
         * recommended ... FIXME
-        *
+        * 
         * @return the Collection of all defined VisualProperties
         */
        public Collection<VisualProperty<?>> collectionOfVisualProperties() {
@@ -137,34 +115,41 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param objectType DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param objectType
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
-       public Collection<VisualProperty<?>> collectionOfVisualProperties(final 
String objectType) {
-               return collectionOfVisualProperties((Collection<View<?>>) null, 
objectType);
+       public Collection<VisualProperty<?>> collectionOfVisualProperties(
+                       final String objectType) {
+               return collectionOfVisualProperties((Collection<View<?>>) null,
+                               objectType);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param networkview DOCUMENT ME!
-        * @param objectType DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param networkview
+        *            DOCUMENT ME!
+        * @param objectType
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
-       public Collection<VisualProperty<?>> collectionOfVisualProperties(final 
CyNetworkView networkview,
-                                                                         final 
String objectType) {
+       public Collection<VisualProperty<?>> collectionOfVisualProperties(
+                       final CyNetworkView networkview, final String 
objectType) {
                if (networkview != null) {
                        // FIXME: could filter Views based on objectType, right 
here
-                       final Collection<View<?>> views = new 
HashSet<View<?>>(networkview.getCyNodeViews());
+                       final Collection<View<?>> views = new 
HashSet<View<?>>(networkview
+                                       .getCyNodeViews());
                        views.addAll(networkview.getCyEdgeViews());
 
                        return collectionOfVisualProperties(views, objectType);
                } else {
-                       return 
collectionOfVisualProperties((Collection<View<?>>) null, objectType);
+                       return 
collectionOfVisualProperties((Collection<View<?>>) null,
+                                       objectType);
                }
        }
 
@@ -172,42 +157,48 @@
         * 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!
+        * 
+        * Note: returns the same as collectionOfVisualProperties() if both 
args are
+        * null.
+        * 
+        * @param views
+        *            DOCUMENT ME!
+        * @param objectType
+        *            DOCUMENT ME!
         * @return VisualProperties
         */
-       public Collection<VisualProperty<?>> collectionOfVisualProperties(final 
Collection<? extends View<?>> views,
-                                                                         final 
String objectType) {
-               final Collection<VisualProperty<?>> allVisualProperties = 
readAllVisualPropertiesFromOSGI();
+       public Collection<VisualProperty<?>> collectionOfVisualProperties(
+                       final Collection<? extends View<?>> views, final String 
objectType) {
 
                if (views == null)
-                       return filterForObjectType(allVisualProperties, 
objectType);
+                       return filterForObjectType(visalPropertySet, 
objectType);
 
-               //System.out.println("making list of VisualProperties in use:");
+               // System.out.println("making list of VisualProperties in 
use:");
                final Set<VisualProperty<?>> toRemove = new 
HashSet<VisualProperty<?>>();
 
                /* apply DependentVisualPropertyCallbacks */
-               for (VisualProperty<?> vp : allVisualProperties) {
-                       final DependentVisualPropertyCallback callback = 
vp.dependentVisualPropertyCallback();
+               for (VisualProperty<?> vp : visalPropertySet) {
+                       final DependentVisualPropertyCallback callback = vp
+                                       .dependentVisualPropertyCallback();
 
                        if (callback != null) {
-                               toRemove.addAll(callback.changed(views, 
allVisualProperties));
+                               toRemove.addAll(callback.changed(views, 
visalPropertySet));
                        }
                }
 
-               //System.out.println("removing:"+toRemove.size());
-               final Set<VisualProperty<?>> result = new 
HashSet<VisualProperty<?>>(allVisualProperties);
+               // System.out.println("removing:"+toRemove.size());
+               final Set<VisualProperty<?>> result = new 
HashSet<VisualProperty<?>>(
+                               visalPropertySet);
                result.removeAll(toRemove);
 
-               //System.out.println("len of result:"+result.size());
+               // System.out.println("len of result:"+result.size());
                return filterForObjectType(result, objectType);
        }
 
        /* return collection of only those that have a matching objectType */
-       private Collection<VisualProperty<?>> filterForObjectType(final 
Collection<? extends VisualProperty<?>> vps,
-                                                                 final String 
objectType) {
+       private Collection<VisualProperty<?>> filterForObjectType(
+                       final Collection<? extends VisualProperty<?>> vps,
+                       final String objectType) {
                final ArrayList<VisualProperty<?>> result = new 
ArrayList<VisualProperty<?>>();
 
                for (VisualProperty<?> vp : vps) {
@@ -219,40 +210,17 @@
                return result;
        }
 
-       private Collection<VisualProperty<?>> readAllVisualPropertiesFromOSGI() 
{
-               final Set<VisualProperty<?>> ret = new 
HashSet<VisualProperty<?>>();
+       // The following two methods are listeners.
+       // Handles dynamics of OSGi services.
 
-               for (Renderer renderer : getAllRenderersFromOSGI()) {
-                       ret.addAll(renderer.getVisualProperties());
-               }
-
-               return ret;
+       @SuppressWarnings("unchecked")
+       public void addRenderer(Renderer renderer, Map props) {
+               System.out.println("====> Renderer bound: " + 
renderer.toString());
+               this.visalPropertySet.addAll(renderer.getVisualProperties());
        }
 
-       private Collection<Renderer> getAllRenderersFromOSGI() {
-               final Set<Renderer> ret = new HashSet<Renderer>();
-
-               if (bundleContext == null)
-                       return ret;
-
-               try {
-                       final ServiceReference[] sr = 
bundleContext.getServiceReferences(Renderer.class.getName(),
-                                                                               
         null);
-
-                       if (sr != null) {
-                               for (ServiceReference r : sr) {
-                                       final Renderer renderer = (Renderer) 
bundleContext.getService(r);
-
-                                       if (renderer != null)
-                                               ret.add(renderer);
-                               }
-                       } else {
-                               System.out.println("sr is null");
-                       }
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-
-               return ret;
+       @SuppressWarnings("unchecked")
+       public void removeRenderer(Renderer renderer, Map props) {
+               this.visalPropertySet.removeAll(renderer.getVisualProperties());
        }
 }

Modified: 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2009-03-12 20:27:51 UTC (rev 16241)
+++ 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2009-03-12 21:21:29 UTC (rev 16242)
@@ -1,24 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xmlns:osgi="http://www.springframework.org/schema/osgi";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                       http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
        default-lazy-init="false">
 
-       <!-- Individual Service -->
-       <osgi:service id="cyNetworkViewFactoryService"
-               ref="cyNetworkViewFactory" 
interface="org.cytoscape.view.model.CyNetworkViewFactory">
+       <!-- Import Services -->
+       <osgi:reference id="cyEventHelperServiceRef" 
interface="org.cytoscape.event.CyEventHelper" />
+
+       <!-- Export Beans as Services -->
+       <osgi:service id="cyNetworkViewFactoryService" 
ref="cyNetworkViewFactory"
+               interface="org.cytoscape.view.model.CyNetworkViewFactory">
                <osgi:service-properties>
                        <entry key="service.type" value="factory" />
                </osgi:service-properties>
        </osgi:service>
 
-       <osgi:service id="visualPropertyCatalogService"
-               ref="visualPropertyCatalog" 
interface="org.cytoscape.view.model.VisualPropertyCatalog">
+       <osgi:service id="visualPropertyCatalogService" 
ref="visualPropertyCatalog"
+               interface="org.cytoscape.view.model.VisualPropertyCatalog">
+               <osgi:service-properties>
+                       <entry key="service.type" value="objectFacade" />
+               </osgi:service-properties>
        </osgi:service>
 
-       <osgi:reference id="cyEventHelperServiceRef"
-               interface="org.cytoscape.event.CyEventHelper">
-       </osgi:reference>
+       <!-- Define OSGi Service Listener -->
+       <osgi:set id="renderers" interface="org.cytoscape.view.model.Renderer"
+               cardinality="0..N">
+               <osgi:listener bind-method="addRenderer" 
unbind-method="removeRenderer"
+                       ref="visualPropertyCatalog" />
+       </osgi:set>
+
 </beans>

Modified: 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
    2009-03-12 20:27:51 UTC (rev 16241)
+++ 
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
    2009-03-12 21:21:29 UTC (rev 16242)
@@ -1,27 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xmlns:context="http://www.springframework.org/schema/context";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:context="http://www.springframework.org/schema/context";
        xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-2.5.xsd";>
 
-       <!-- regular spring configuration file defining the beans for this
-               bundle. We've kept the osgi definitions in a separate 
-               configuration file so that this file can easily be used
-               for integration testing outside of an OSGi environment -->
+       <context:annotation-config />
 
-       <context:annotation-config/>
-       
-       <bean id="cyNetworkViewFactory" 
class="org.cytoscape.view.model.internal.ColumnOrientedNetworkViewFactoryImpl">
-         <property name="eventHelper" ref="cyEventHelperServiceRef"></property>
-         <property name="bundleContext" ref="bundleContext"></property>
+       <!-- Factory bean for views and this will be exported as service. -->
+       <bean id="cyNetworkViewFactory"
+               
class="org.cytoscape.view.model.internal.ColumnOrientedNetworkViewFactoryImpl">
+               <constructor-arg ref="cyEventHelperServiceRef" />
        </bean>
 
-       <bean id="visualPropertyCatalog" 
class="org.cytoscape.view.model.internal.VisualPropertyCatalogImpl">
-         <property name="bundleContext" ref="bundleContext"></property>
-       </bean>
+       <!-- Catalog object of available VP.  This will be exported as service. 
-->
+       <bean id="visualPropertyCatalog"
+               
class="org.cytoscape.view.model.internal.VisualPropertyCatalogImpl" />
 
 </beans>


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