Author: kono
Date: 2010-09-16 18:48:41 -0700 (Thu, 16 Sep 2010)
New Revision: 21916

Added:
   core3/vizmap-impl/branches/vp-tree/src/integration/
   core3/vizmap-impl/branches/vp-tree/src/integration/java/
   core3/vizmap-impl/branches/vp-tree/src/integration/java/integration/
   
core3/vizmap-impl/branches/vp-tree/src/integration/java/integration/ITVzmapImpl.java
   
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleFactoryImpl.java
   
core3/vizmap-impl/branches/vp-tree/src/test/java/org/cytoscape/vizmap/VisualStyleTest.java
   core3/vizmap-impl/branches/vp-tree/src/test/resources/
   core3/vizmap-impl/branches/vp-tree/src/test/resources/log4j.properties
Modified:
   core3/vizmap-impl/branches/vp-tree/pom.xml
   
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
   
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
   
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Refactored version of VP tree.  VisualLexicons are moved to presentation layer.

Modified: core3/vizmap-impl/branches/vp-tree/pom.xml
===================================================================
--- core3/vizmap-impl/branches/vp-tree/pom.xml  2010-09-17 01:30:47 UTC (rev 
21915)
+++ core3/vizmap-impl/branches/vp-tree/pom.xml  2010-09-17 01:48:41 UTC (rev 
21916)
@@ -62,6 +62,50 @@
                                        </instructions>
                                </configuration>
                        </plugin>
+
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               
<artifactId>build-helper-maven-plugin</artifactId>
+                               <version>1.5</version>
+                               <executions>
+                                       <execution>
+                                               <id>add-test-source</id>
+                                               
<phase>generate-test-sources</phase>
+                                               <goals>
+                                                       
<goal>add-test-source</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <sources>
+                                                               
<source>${basedir}/src/integration/java</source>
+                                                       </sources>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-failsafe-plugin</artifactId>
+                               <version>2.6</version>
+                               <configuration>
+                                       
<testSourceDirectory>${basedir}/src/integration/java</testSourceDirectory>
+                                       
<redirectTestOutputToFile>true</redirectTestOutputToFile>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>integration-test</id>
+                                               <goals>
+                                                       
<goal>integration-test</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>verify</id>
+                                               <goals>
+                                                       <goal>verify</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
                </plugins>
        </build>
 
@@ -107,5 +151,11 @@
                        <version>${junit.version}</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>integration-test-support</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+                       <scope>test</scope>
+               </dependency>
        </dependencies>
 </project>

Added: 
core3/vizmap-impl/branches/vp-tree/src/integration/java/integration/ITVzmapImpl.java
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/integration/java/integration/ITVzmapImpl.java
                                (rev 0)
+++ 
core3/vizmap-impl/branches/vp-tree/src/integration/java/integration/ITVzmapImpl.java
        2010-09-17 01:48:41 UTC (rev 21916)
@@ -0,0 +1,30 @@
+package integration;
+
+import org.cytoscape.integration.AbstractIntegrationTester;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+
+public class ITVzmapImpl extends AbstractIntegrationTester {
+
+       public ITVzmapImpl() {
+               super("org.cytoscape.view.vizmap-impl", 
+                               
+                               new String[] {
+                               "org.cytoscape, event-api, 1.0-SNAPSHOT",
+                               "org.cytoscape, event-impl, 1.0-SNAPSHOT",
+                               "org.cytoscape, model-api, 1.0-SNAPSHOT",
+                               "org.cytoscape, integration-test-support, 
1.0-SNAPSHOT",
+                               "org.cytoscape, service-util, 1.0-SNAPSHOT",
+                               "org.cytoscape, viewmodel-api, 1.0-SNAPSHOT",
+                               "org.cytoscape, viewmodel-impl, 1.0-SNAPSHOT",
+                               "org.cytoscape, vizmap-api, 1.0-SNAPSHOT",
+                               "org.cytoscape, vizmap-impl, 1.0-SNAPSHOT",
+                               "org.cytoscape, presentation-api, 1.0-SNAPSHOT"
+                               
+                               },
+                               new String[] { "visualStyleFactory", 
"visualMappingManager" },
+                               new Class[] { VisualStyleFactory.class, 
VisualMappingManager.class },
+                               new String[] { });
+       }
+
+}

Modified: 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
   2010-09-17 01:30:47 UTC (rev 21915)
+++ 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
   2010-09-17 01:48:41 UTC (rev 21916)
@@ -34,7 +34,6 @@
  */
 package org.cytoscape.view.vizmap.internal;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -42,12 +41,8 @@
 
 import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.VisualLexiconManager;
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.vizmap.VisualMappingFunction;
 import org.cytoscape.view.vizmap.VisualMappingManager;
 import org.cytoscape.view.vizmap.VisualStyle;
-import org.cytoscape.view.vizmap.events.VisualStyleCreatedEvent;
 import org.cytoscape.view.vizmap.events.VisualStyleDestroyedEvent;
 
 
@@ -56,30 +51,20 @@
  */
 public class VisualMappingManagerImpl implements VisualMappingManager {
        
-       private final Map<CyNetworkView, VisualStyle> vsForNetwork;
+       private final Map<CyNetworkView, VisualStyle> network2VisualStyleMap;
        private final Set<VisualStyle> visualStyles;
        
-       private CyEventHelper cyEventHelper;
-       private VisualLexiconManager rootLexicon;
+       private final CyEventHelper cyEventHelper;
        
-       /**
-        *
-        * @param h
-        *            DOCUMENT ME!
-        */
-       public VisualMappingManagerImpl(final CyEventHelper eventHelper,
-                                       final VisualLexiconManager rootLexicon) 
{
+       
+       public VisualMappingManagerImpl(final CyEventHelper eventHelper) {
                if (eventHelper == null)
                        throw new IllegalArgumentException("CyEventHelper 
cannot be null");
 
-               if (rootLexicon == null)
-                       throw new IllegalArgumentException("vpCatalog cannot be 
null");
-
                this.cyEventHelper = eventHelper;
-               this.rootLexicon = rootLexicon;
 
                visualStyles = new HashSet<VisualStyle>();
-               vsForNetwork = new HashMap<CyNetworkView, VisualStyle>();
+               network2VisualStyleMap = new HashMap<CyNetworkView, 
VisualStyle>();
        }
 
        /**
@@ -90,8 +75,8 @@
         *
         * @return DOCUMENT ME!
         */
-       public VisualStyle getVisualStyle(CyNetworkView nv) {
-               return vsForNetwork.get(nv);
+       @Override public VisualStyle getVisualStyle(CyNetworkView nv) {
+               return network2VisualStyleMap.get(nv);
        }
 
        /**
@@ -102,78 +87,34 @@
         * @param nv
         *            DOCUMENT ME!
         */
-       public void setVisualStyle(VisualStyle vs, CyNetworkView nv) {
-               vsForNetwork.put(nv, vs);
+       @Override public void setVisualStyle(VisualStyle vs, CyNetworkView nv) {
+               network2VisualStyleMap.put(nv, vs);
        }
 
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param originalVS DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public VisualStyle copyVisualStyle(VisualStyle originalVS) {
-               final VisualStyle copyVS = new VisualStyleImpl(rootLexicon, 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 
VisualStyleCreatedEvent(this,copyVS));
-
-               return copyVS;
-       }
-
        /**
-        *  DOCUMENT ME!
-        *
-        * @param title DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       public VisualStyle createVisualStyle(String title) {
-               final VisualStyle newVS = new VisualStyleImpl(rootLexicon, 
title);
-               visualStyles.add(newVS);
-               cyEventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEvent(this,newVS));
-
-               return newVS;
-       }
-
-       /**
         * Remove the style from this manager and delete it.
         *
         * @param vs
         *            DOCUMENT ME!
         */
-       public void removeVisualStyle(VisualStyle vs) {
+       @Override public void removeVisualStyle(VisualStyle vs) {
                visualStyles.remove(vs);
                cyEventHelper.fireSynchronousEvent(new 
VisualStyleDestroyedEvent(this,vs));
                vs = null;
        }
+       
 
        /**
         *  DOCUMENT ME!
         *
         * @return  DOCUMENT ME!
         */
-       public Collection<VisualStyle> getAllVisualStyles() {
+       @Override public Set<VisualStyle> getAllVisualStyles() {
                return visualStyles;
        }
 
-
-       public <K, V> VisualMappingFunction<K, V> createMapping(String 
mappingType,
-                       String attrName, Class<K> attrType, VisualProperty<V> 
vp) {
-               
-               
-               return null;
+       @Override public void addVisualStyle(VisualStyle vs) {
+               this.visualStyles.add(vs);
        }
 }

Added: 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleFactoryImpl.java
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleFactoryImpl.java
                             (rev 0)
+++ 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleFactoryImpl.java
     2010-09-17 01:48:41 UTC (rev 21916)
@@ -0,0 +1,50 @@
+package org.cytoscape.view.vizmap.internal;
+
+import java.util.Collection;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.RenderingEngine;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+import org.cytoscape.view.vizmap.events.VisualStyleCreatedEvent;
+
+public class VisualStyleFactoryImpl implements VisualStyleFactory {
+       
+       private final CyEventHelper eventHelper;
+       
+       public VisualStyleFactoryImpl(final CyEventHelper eventHelper) {
+               this.eventHelper = eventHelper;
+       }
+
+       @Override
+       public VisualStyle createVisualStyle(final VisualStyle original) {
+               final VisualStyle copyVS = new 
VisualStyleImpl(original.getTitle(), original.getVisualLexicon());
+               
+               // TODO: copy everything! This is incomplete
+               Collection<VisualMappingFunction<?, ?>> allMapping = 
original.getAllVisualMappingFunctions();
+
+               String attrName;
+               VisualProperty<?> vp;
+
+               for (VisualMappingFunction<?, ?> mapping : allMapping) {
+                       attrName = mapping.getMappingAttributeName();
+                       vp = mapping.getVisualProperty();
+               }
+
+               eventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEvent(this,copyVS));
+
+               return copyVS;
+       }
+       
+
+       @Override
+       public VisualStyle createVisualStyle(String title, RenderingEngine<?> 
engine) {
+               final VisualStyle vs = new VisualStyleImpl(title, 
engine.getVisualLexicon());
+               
+               eventHelper.fireSynchronousEvent(new 
VisualStyleCreatedEvent(this,vs));
+               return vs;
+       }
+
+}

Modified: 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
    2010-09-17 01:30:47 UTC (rev 21915)
+++ 
core3/vizmap-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
    2010-09-17 01:48:41 UTC (rev 21916)
@@ -36,17 +36,14 @@
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 
 import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyTableEntry;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualLexicon;
-import org.cytoscape.view.model.VisualLexiconManager;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.vizmap.VisualMappingFunction;
 import org.cytoscape.view.vizmap.VisualStyle;
@@ -64,8 +61,9 @@
 
        private final Map<VisualProperty<?>, VisualMappingFunction<?, ?>> 
mappings;
        private final Map<VisualProperty<?>, Object> perVSDefaults;
-       private final VisualLexiconManager lexiconManager;
 
+       private final VisualLexicon lexicon;
+       
        private String title;
 
        /**
@@ -74,8 +72,8 @@
         * @param rootLexicon
         *            DOCUMENT ME!
         */
-       public VisualStyleImpl(final VisualLexiconManager lexiconManager) {
-               this(lexiconManager, null);
+       public VisualStyleImpl(final VisualLexicon lexicon) {
+               this(null, lexicon);
        }
 
        /**
@@ -86,24 +84,22 @@
         * @param rootLexicon
         *            DOCUMENT ME!
         */
-       public VisualStyleImpl(final VisualLexiconManager lexiconManager,
-                       final String title) {
-               if (lexiconManager == null)
-                       throw new NullPointerException("rootLexicon is null");
+       public VisualStyleImpl(final String title, final VisualLexicon lexicon) 
{
+               if (lexicon == null)
+                       throw new NullPointerException("Lexicon is null");
 
                if (title == null)
                        this.title = DEFAULT_TITLE;
                else
                        this.title = title;
 
-               this.lexiconManager = lexiconManager;
+               this.lexicon = lexicon;
                mappings = new HashMap<VisualProperty<?>, 
VisualMappingFunction<?, ?>>();
                perVSDefaults = new HashMap<VisualProperty<?>, Object>();
 
-               // Copy immutable defaults from each VP
-               final VisualLexicon root = lexiconManager.getLexicon();
+               
 
-               for (VisualProperty<?> vp : root.getAllVisualProperties())
+               for (VisualProperty<?> vp : lexicon.getAllVisualProperties())
                        perVSDefaults.put(vp, vp.getDefault());
 
                logger.info("New Visual Style Created: Style Name = " + 
this.title);
@@ -201,7 +197,6 @@
                // networkviews.add(networkView);
 
                // Current visual prop tree.
-               final VisualLexicon lexicon = lexiconManager.getLexicon();
                Collection<View<? extends CyTableEntry>> allViews = networkView
                                .getAllViews();
                applyImpl(allViews, lexicon.getAllVisualProperties());
@@ -321,8 +316,9 @@
        }
 
        // TODO Is this the right set of lexicon?
+       @Override
        public VisualLexicon getVisualLexicon() {
-               return lexiconManager.getLexicon();
+               return lexicon;
        }
 
 }

Modified: 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2010-09-17 01:30:47 UTC (rev 21915)
+++ 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2010-09-17 01:48:41 UTC (rev 21916)
@@ -5,13 +5,18 @@
                       http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
        default-lazy-init="false">
 
+
+       <!-- Export VMM as an OSGi Service -->
        <osgi:service id="visualMappingManagerService" 
ref="visualMappingManager"
                interface="org.cytoscape.view.vizmap.VisualMappingManager">
        </osgi:service>
+       
+       <!-- Export Visual Style Factory as an OSGi Service -->
+       <osgi:service id="visualStyleFactoryService" ref="visualStyleFactory"
+               interface="org.cytoscape.view.vizmap.VisualStyleFactory">
+       </osgi:service>
 
        <!-- Import Services -->
        <osgi:reference id="cyEventHelperServiceRef" 
interface="org.cytoscape.event.CyEventHelper" />
 
-       <osgi:reference id="rootVisualLexiconRef"
-               interface="org.cytoscape.view.model.RootVisualLexicon" />
 </beans>

Modified: 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
    2010-09-17 01:30:47 UTC (rev 21915)
+++ 
core3/vizmap-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context.xml
    2010-09-17 01:48:41 UTC (rev 21916)
@@ -13,14 +13,19 @@
            http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
             http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
        default-lazy-init="false">
+       
+       <import resource="bundle-context-osgi.xml" />
 
        <context:annotation-config />
 
        <bean id="visualMappingManager"
                
class="org.cytoscape.view.vizmap.internal.VisualMappingManagerImpl">
                <constructor-arg ref="cyEventHelperServiceRef" />
-               <constructor-arg ref="rootVisualLexiconRef" />
        </bean>
+       
+       <bean id="visualStyleFactory"
+               
class="org.cytoscape.view.vizmap.internal.VisualStyleFactoryImpl">
+               <constructor-arg ref="cyEventHelperServiceRef" />
+       </bean>
 
-
 </beans>

Added: 
core3/vizmap-impl/branches/vp-tree/src/test/java/org/cytoscape/vizmap/VisualStyleTest.java
===================================================================
--- 
core3/vizmap-impl/branches/vp-tree/src/test/java/org/cytoscape/vizmap/VisualStyleTest.java
                          (rev 0)
+++ 
core3/vizmap-impl/branches/vp-tree/src/test/java/org/cytoscape/vizmap/VisualStyleTest.java
  2010-09-17 01:48:41 UTC (rev 21916)
@@ -0,0 +1,23 @@
+package org.cytoscape.vizmap;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class VisualStyleTest {
+
+       @Before
+       public void setUp() throws Exception {
+       }
+
+       @After
+       public void tearDown() throws Exception {
+       }
+       
+       @Test
+       public void testVisualStyle() {
+               
+       }
+
+}

Added: core3/vizmap-impl/branches/vp-tree/src/test/resources/log4j.properties
===================================================================
--- core3/vizmap-impl/branches/vp-tree/src/test/resources/log4j.properties      
                        (rev 0)
+++ core3/vizmap-impl/branches/vp-tree/src/test/resources/log4j.properties      
2010-09-17 01:48:41 UTC (rev 21916)
@@ -0,0 +1,8 @@
+log4j.rootCategory=info, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout.ConversionPattern=%t %p [%c] - %m%n
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.threshold=TRACE
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.springframework.osgi.test=INFO


Property changes on: 
core3/vizmap-impl/branches/vp-tree/src/test/resources/log4j.properties
___________________________________________________________________
Name: svn:executable
   + *

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