Author: kono
Date: 2009-04-24 11:57:15 -0700 (Fri, 24 Apr 2009)
New Revision: 16690

Removed:
   
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualStyleCatalog.java
   
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleCatalogImpl.java
Modified:
   
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualMappingManager.java
   
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
Log:
VisualMappingManager includes the functions of VisualStyleCatalog.

Modified: 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualMappingManager.java
===================================================================
--- 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualMappingManager.java
    2009-04-24 02:46:25 UTC (rev 16689)
+++ 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualMappingManager.java
    2009-04-24 18:57:15 UTC (rev 16690)
@@ -1,14 +1,110 @@
+
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ 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.vizmap;
 
+import java.util.Collection;
+
 import org.cytoscape.view.model.CyNetworkView;
 
+
 /**
- * From pre-3.0 functionality, only 'network->VisualStyle' map remains in here.
+ * Managing mapping from View --> Visual Style.
+ * Also, this class manages list of all available Visual Styles.
+ * Creation/deletion of VS is a function of this class.  
+ *
  * @author abeld
+ * @author kono
+ * 
+ * @since Cytoscape 3.0
  *
  */
 public interface VisualMappingManager {
-       
+       /**
+        *  Set a Visual Style to the target view
+        *
+        * @param vs Visual Style to be set.
+        * @param nv Target network view
+        */
        public void setVisualStyle(VisualStyle vs, CyNetworkView nv);
+
+       /**
+        *  Returns the associated Visual Style for the target view.
+        *
+        * @param nv Target network view
+        *
+        * @return  Associated Visual Style for the view.
+        */
        public VisualStyle getVisualStyle(CyNetworkView nv);
+
+       /**
+        * Create a copy of given Visual Style.
+        *
+        * @param originalVS
+        *            VS to be copied from.
+        *
+        * @return Copied VS
+        */
+       public VisualStyle copyVisualStyle(VisualStyle originalVS);
+
+       /**
+        * Create a new Visual Style.
+        * 
+        * @param title Title of the visual style.  This can be null, but in 
that case, 
+        *                                      default title will be used.
+        *                      Note: This is NOT an identifier of this object, 
just a title.
+        *
+        * @return New Visual Style
+        */
+       public VisualStyle createVisualStyle(String title);
+
+       /**
+        * Returns all available Visual Styles managed by this object.
+        *
+        * @return Collection of all available Visual Styles.
+        * 
+        * TODO: Collection or Set? 
+        */
+       public Collection<VisualStyle> getAllVisualStyles();
+
+       /**
+        * Remove a Visual Style.
+        *
+        * @param vs Visual Style to be removed.
+        * 
+        */
+       public void removeVisualStyle(VisualStyle vs);
 }

Deleted: 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualStyleCatalog.java
===================================================================
--- 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualStyleCatalog.java
      2009-04-24 02:46:25 UTC (rev 16689)
+++ 
core3/vizmap-api/trunk/src/main/java/org/cytoscape/view/vizmap/VisualStyleCatalog.java
      2009-04-24 18:57:15 UTC (rev 16690)
@@ -1,75 +0,0 @@
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- 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.vizmap;
-
-import java.util.List;
-
-
-/**
- * We need a list of currently-used VisualStyles somewhere (?)
- * This is it.
- * It is also a VisualStyle factory
- */
-public interface VisualStyleCatalog {
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       VisualStyle createVisualStyle(String title);
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param originalVS DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public VisualStyle copyVisualStyle(VisualStyle originalVS);
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       List<VisualStyle> listOfVisualStyles();
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param vs DOCUMENT ME!
-        */
-       void removeVisualStyle(VisualStyle vs);
-}

Modified: 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
===================================================================
--- 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
      2009-04-24 02:46:25 UTC (rev 16689)
+++ 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
      2009-04-24 18:57:15 UTC (rev 16690)
@@ -1,4 +1,3 @@
-
 /*
  Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
 
@@ -32,49 +31,145 @@
  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.vizmap.internal;
 
+import org.cytoscape.event.CyEventHelper;
+
 import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.model.VisualPropertyCatalog;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
 import org.cytoscape.view.vizmap.VisualMappingManager;
 import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.events.VisualStyleCreatedListener;
+import org.cytoscape.view.vizmap.events.VisualStyleDestroyedListener;
+import org.cytoscape.view.vizmap.internal.events.VisualStyleCreatedEventImpl;
+import org.cytoscape.view.vizmap.internal.events.VisualStyleDestroyedEventImpl;
 
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 
 /**
  *
  */
 public class VisualMappingManagerImpl implements VisualMappingManager {
-       private HashMap<CyNetworkView, VisualStyle> vsForNetwork;
+       private final Map<CyNetworkView, VisualStyle> vsForNetwork;
+       private final Set<VisualStyle> visualStyles;
+       private CyEventHelper cyEventHelper;
+       private VisualPropertyCatalog vpCatalog;
 
        /**
-        * Creates a new VisualMappingManagerImpl object.
+        *
+        * @param h
+        *            DOCUMENT ME!
         */
-       public VisualMappingManagerImpl() {
+       public VisualMappingManagerImpl(final CyEventHelper eventHelper,
+                                       final VisualPropertyCatalog vpCatalog) {
+               if (eventHelper == null)
+                       throw new IllegalArgumentException("CyEventHelper 
cannot be null");
+
+               if (vpCatalog == null)
+                       throw new IllegalArgumentException("vpCatalog cannot be 
null");
+
+               this.cyEventHelper = eventHelper;
+               this.vpCatalog = vpCatalog;
+
+               visualStyles = new HashSet<VisualStyle>();
                vsForNetwork = new HashMap<CyNetworkView, VisualStyle>();
        }
 
        /**
-        *  DOCUMENT ME!
+        * DOCUMENT ME!
         *
-        * @param nv DOCUMENT ME!
+        * @param nv
+        *            DOCUMENT ME!
         *
-        * @return  DOCUMENT ME!
+        * @return DOCUMENT ME!
         */
        public VisualStyle getVisualStyle(CyNetworkView nv) {
                return vsForNetwork.get(nv);
        }
 
        /**
-        *  DOCUMENT ME!
+        * DOCUMENT ME!
         *
-        * @param vs DOCUMENT ME!
-        * @param nv DOCUMENT ME!
+        * @param vs
+        *            DOCUMENT ME!
+        * @param nv
+        *            DOCUMENT ME!
         */
        public void setVisualStyle(VisualStyle vs, CyNetworkView nv) {
-               // TODO Auto-generated method stub
                vsForNetwork.put(nv, vs);
        }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @param originalVS DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public VisualStyle copyVisualStyle(VisualStyle originalVS) {
+               final VisualStyle copyVS = new VisualStyleImpl(vpCatalog, new 
String(originalVS.getTitle()));
+
+               // TODO: copy everything! This is incomplete
+               Collection<VisualMappingFunction<?, ?>> allMapping = 
originalVS.getAllVisualMappingFunctions();
+
+               String attrName;
+               VisualProperty<?> vp;
+
+               for (VisualMappingFunction<?, ?> mapping : allMapping) {
+                       attrName = mapping.getMappingAttributeName();
+                       vp = mapping.getVisualProperty();
+               }
+
+               visualStyles.add(copyVS);
+               cyEventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEventImpl(copyVS),
+                                                  
VisualStyleCreatedListener.class);
+
+               return copyVS;
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @param title DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public VisualStyle createVisualStyle(String title) {
+               final VisualStyle newVS = new VisualStyleImpl(vpCatalog, title);
+               visualStyles.add(newVS);
+               cyEventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEventImpl(newVS),
+                                                  
VisualStyleCreatedListener.class);
+
+               return newVS;
+       }
+
+       /**
+        * Remove the style from this manager and delete it.
+        *
+        * @param vs
+        *            DOCUMENT ME!
+        */
+       public void removeVisualStyle(VisualStyle vs) {
+               visualStyles.remove(vs);
+               cyEventHelper.fireSynchronousEvent(new 
VisualStyleDestroyedEventImpl(vs),
+                                                  
VisualStyleDestroyedListener.class);
+               vs = null;
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public Collection<VisualStyle> getAllVisualStyles() {
+               return visualStyles;
+       }
 }

Deleted: 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleCatalogImpl.java
===================================================================
--- 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleCatalogImpl.java
        2009-04-24 02:46:25 UTC (rev 16689)
+++ 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleCatalogImpl.java
        2009-04-24 18:57:15 UTC (rev 16690)
@@ -1,173 +0,0 @@
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- 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.vizmap.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.model.VisualPropertyCatalog;
-import org.cytoscape.view.vizmap.VisualMappingFunction;
-import org.cytoscape.view.vizmap.VisualStyle;
-import org.cytoscape.view.vizmap.VisualStyleCatalog;
-import org.cytoscape.view.vizmap.events.VisualStyleCreatedListener;
-import org.cytoscape.view.vizmap.events.VisualStyleDestroyedListener;
-import org.cytoscape.view.vizmap.internal.events.VisualStyleCreatedEventImpl;
-import org.cytoscape.view.vizmap.internal.events.VisualStyleDestroyedEventImpl;
-
-
-/**
- * We need a list of currently-used VisualStyles somewhere (?)
- * This is it.
- * It is also a VisualStyle factory
- */
-public class VisualStyleCatalogImpl implements VisualStyleCatalog {
-       private final Set<VisualStyle> visualStyles;
-       private CyEventHelper cyEventHelper;
-       private VisualPropertyCatalog vpCatalog;
-       
-       /**
-        * For setter injection (hmm. whats that?)
-        */
-       public VisualStyleCatalogImpl() {
-               visualStyles = new HashSet<VisualStyle>();
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param eventHelper DOCUMENT ME!
-        */
-       public void setEventHelper(final CyEventHelper eventHelper) {
-               this.cyEventHelper = eventHelper;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public CyEventHelper getEventHelper() {
-               return this.cyEventHelper;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param vpCatalog DOCUMENT ME!
-        */
-       public void setVisualPropertyCatalog(final VisualPropertyCatalog 
vpCatalog) {
-               this.vpCatalog = vpCatalog;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public VisualPropertyCatalog getVisualPropertyCatalog() {
-               return this.vpCatalog;
-       }
-
-       /**
-        * 
-        * @param h  DOCUMENT ME!
-        */
-       public VisualStyleCatalogImpl(final CyEventHelper eventHelper,
-                                     final VisualPropertyCatalog vpCatalog) {
-               if (eventHelper == null)
-                       throw new NullPointerException("CyEventHelper is null");
-
-               if (vpCatalog == null)
-                       throw new NullPointerException("vpCatalog is null");
-
-               this.cyEventHelper = eventHelper;
-               this.vpCatalog = vpCatalog;
-               visualStyles = new HashSet<VisualStyle>();
-       }
-       
-       public VisualStyle createVisualStyle(String title) {
-               final VisualStyle newVS = new VisualStyleImpl(vpCatalog, title);
-               visualStyles.add(newVS);
-               cyEventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEventImpl(newVS),
-                                                
VisualStyleCreatedListener.class);
-
-               return newVS;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public List<VisualStyle> listOfVisualStyles() {
-               return new ArrayList<VisualStyle>(visualStyles);
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param vs DOCUMENT ME!
-        */
-       public void removeVisualStyle(final VisualStyle vs) {
-               visualStyles.remove(vs);
-               cyEventHelper.fireSynchronousEvent(new 
VisualStyleDestroyedEventImpl(vs),
-                                                
VisualStyleDestroyedListener.class);
-       }
-
-       public VisualStyle copyVisualStyle(VisualStyle originalVS) {
-               
-               final VisualStyle copyVS = new VisualStyleImpl(vpCatalog, new 
String(originalVS.getTitle()));
-               //TODO: copy everything!
-               Collection<VisualMappingFunction<?, ?>> allMapping = 
originalVS.getAllVisualMappingFunctions();
-               
-               String attrName;
-               VisualProperty<?> vp;
-               for(VisualMappingFunction<?,?> mapping:allMapping) {
-                       attrName = mapping.getMappingAttributeName();
-                       vp = mapping.getVisualProperty();
-                       
-               }
-               
-               visualStyles.add(copyVS);
-               cyEventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEventImpl(copyVS),
-                                                
VisualStyleCreatedListener.class);
-               return copyVS;
-       }
-}


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