Author: Christian Lopes
Date: 2011-06-13 09:07:49 -0700 (Mon, 13 Jun 2011)
New Revision: 25721

Removed:
   
core3/vizmap-impl/trunk/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerImpl.java
   
core3/vizmap-impl/trunk/impl/src/test/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerTest.java
Modified:
   core3/vizmap-impl/trunk/impl/pom.xml
   
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
   core3/vizmap-impl/trunk/it/pom.xml
   
core3/vizmap-impl/trunk/it/src/test/java/org/cytoscape/view/vizmap/ServiceConfigurationTest.java
   core3/vizmap-impl/trunk/pom.xml
Log:
Removed the implementation and the OSGI service of the VisualStyleSerializer.

Modified: core3/vizmap-impl/trunk/impl/pom.xml
===================================================================
--- core3/vizmap-impl/trunk/impl/pom.xml        2011-06-13 15:46:12 UTC (rev 
25720)
+++ core3/vizmap-impl/trunk/impl/pom.xml        2011-06-13 16:07:49 UTC (rev 
25721)
@@ -4,7 +4,7 @@
        <parent>
                <artifactId>vizmap-impl-parent</artifactId>
                <groupId>org.cytoscape</groupId>
-               <version>3.0.0-alpha4-SNAPSHOT</version>
+               <version>3.0.0-alpha5-SNAPSHOT</version>
        </parent>
 
        <properties>

Deleted: 
core3/vizmap-impl/trunk/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerImpl.java
===================================================================
--- 
core3/vizmap-impl/trunk/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerImpl.java
        2011-06-13 15:46:12 UTC (rev 25720)
+++ 
core3/vizmap-impl/trunk/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerImpl.java
        2011-06-13 16:07:49 UTC (rev 25721)
@@ -1,423 +0,0 @@
-/*
- Copyright (c) 2010, 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.math.BigDecimal;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-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.VisualLexicon;
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.model.Visualizable;
-import org.cytoscape.view.presentation.RenderingEngineManager;
-import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
-import org.cytoscape.view.vizmap.VisualMappingFunction;
-import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
-import org.cytoscape.view.vizmap.VisualMappingManager;
-import org.cytoscape.view.vizmap.VisualStyle;
-import org.cytoscape.view.vizmap.VisualStyleFactory;
-import org.cytoscape.view.vizmap.VisualStyleSerializer;
-import org.cytoscape.view.vizmap.mappings.BoundaryRangeValues;
-import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
-import org.cytoscape.view.vizmap.mappings.ContinuousMappingPoint;
-import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
-import org.cytoscape.view.vizmap.mappings.PassthroughMapping;
-import org.cytoscape.view.vizmap.model.AttributeType;
-import org.cytoscape.view.vizmap.model.DiscreteMappingEntry;
-import org.cytoscape.view.vizmap.model.Edges;
-import org.cytoscape.view.vizmap.model.Network;
-import org.cytoscape.view.vizmap.model.Nodes;
-import org.cytoscape.view.vizmap.model.Vizmap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * So far this implementation handles only 2.x vizmap properties.
- * 
- * @author Christian
- */
-public class VisualStyleSerializerImpl implements VisualStyleSerializer {
-
-    private final VisualStyleFactory visualStyleFactory;
-    private final VisualMappingManager visualMappingManager;
-    private final RenderingEngineManager renderingEngineManager;
-    private final VisualMappingFunctionFactory discreteMappingFactory;
-    private final VisualMappingFunctionFactory continuousMappingFactory;
-    private final VisualMappingFunctionFactory passthroughMappingFactory;
-
-    private VisualLexicon lexicon;
-
-    private static final Logger logger = 
LoggerFactory.getLogger(VisualStyleSerializerImpl.class);
-
-    public VisualStyleSerializerImpl(final VisualStyleFactory 
visualStyleFactory,
-                                     final VisualMappingManager 
visualMappingManager,
-                                     final RenderingEngineManager 
renderingEngineManager,
-                                     final VisualMappingFunctionFactory 
discreteMappingFactory,
-                                     final VisualMappingFunctionFactory 
continuousMappingFactory,
-                                     final VisualMappingFunctionFactory 
passthroughMappingFactory) {
-        this.visualStyleFactory = visualStyleFactory;
-        this.visualMappingManager = visualMappingManager;
-        this.renderingEngineManager = renderingEngineManager;
-        this.discreteMappingFactory = discreteMappingFactory;
-        this.continuousMappingFactory = continuousMappingFactory;
-        this.passthroughMappingFactory = passthroughMappingFactory;
-    }
-
-    @Override
-    public Vizmap createVizmap(Collection<VisualStyle> styles) {
-        Vizmap vizmap = new Vizmap();
-        lexicon = renderingEngineManager.getDefaultVisualLexicon();
-
-        if (styles != null) {
-            for (VisualStyle vs : styles) {
-                org.cytoscape.view.vizmap.model.VisualStyle vsModel = new 
org.cytoscape.view.vizmap.model.VisualStyle();
-                vizmap.getVisualStyle().add(vsModel);
-
-                vsModel.setName(vs.getTitle());
-
-                vsModel.setNetwork(new Network());
-                vsModel.setNodes(new Nodes());
-                vsModel.setEdges(new Edges());
-
-                createVizmapProperties(vs, MinimalVisualLexicon.NETWORK, 
vsModel.getNetwork().getVisualProperty());
-                createVizmapProperties(vs, MinimalVisualLexicon.NODE, 
vsModel.getNodes().getVisualProperty());
-                createVizmapProperties(vs, MinimalVisualLexicon.EDGE, 
vsModel.getEdges().getVisualProperty());
-            }
-        }
-
-        return vizmap;
-    }
-
-    @Override
-    public Collection<VisualStyle> createVisualStyles(Vizmap vizmap) {
-        Set<VisualStyle> styles = new HashSet<VisualStyle>();
-        lexicon = renderingEngineManager.getDefaultVisualLexicon();
-        VisualStyle defaultStyle = 
visualMappingManager.getDefaultVisualStyle();
-
-        if (lexicon == null) {
-            logger.warn("Cannot create visual styles because there is no 
default Visual Lexicon");
-            return styles;
-        }
-
-        if (vizmap != null) {
-            List<org.cytoscape.view.vizmap.model.VisualStyle> vsModelList = 
vizmap.getVisualStyle();
-
-            for (org.cytoscape.view.vizmap.model.VisualStyle vsModel : 
vsModelList) {
-                String styleName = vsModel.getName();
-
-                // Each new style should be created from the default one:
-                VisualStyle vs = null;
-
-                if 
(styleName.equals(VisualMappingManagerImpl.DEFAULT_STYLE_NAME)) {
-                    // If loading the default style, do not create another one,
-                    // but just modify the current default object!
-                    vs = defaultStyle;
-                    // TODO: delete mappings?
-                } else {
-                    vs = visualStyleFactory.getInstance(defaultStyle);
-                    vs.setTitle(styleName);
-                }
-
-                // Set the visual properties and mappings:
-                createVisualProperties(vs, CyNetwork.class, 
vsModel.getNetwork().getVisualProperty());
-                createVisualProperties(vs, CyNode.class, 
vsModel.getNodes().getVisualProperty());
-                createVisualProperties(vs, CyEdge.class, 
vsModel.getEdges().getVisualProperty());
-
-                // Do not add the modified default style to the list!
-                if (!vs.equals(defaultStyle)) styles.add(vs);
-            }
-        }
-
-        return styles;
-    }
-
-    private <K, V> void createVizmapProperties(VisualStyle vs,
-                                            VisualProperty<Visualizable> root,
-                                            
List<org.cytoscape.view.vizmap.model.VisualProperty> vpModelList) {
-        Collection<VisualProperty<?>> vpList = lexicon.getAllDescendants(root);
-        Iterator<VisualProperty<?>> iter = vpList.iterator();
-
-        while (iter.hasNext()) {
-            VisualProperty<V> vp = (VisualProperty<V>) iter.next();
-
-            // NETWORK root includes NODES and EDGES, but we want to separate 
the CyNetwork properties!
-            if (root == MinimalVisualLexicon.NETWORK && vp.getTargetDataType() 
!= CyNetwork.class) continue;
-
-            V defValue = vs.getDefaultValue(vp);
-            VisualMappingFunction<?, V> mapping = 
vs.getVisualMappingFunction(vp);
-
-            if (defValue != null || mapping != null) {
-                org.cytoscape.view.vizmap.model.VisualProperty vpModel = new 
org.cytoscape.view.vizmap.model.VisualProperty();
-                vpModel.setName(vp.getIdString());
-
-                vpModelList.add(vpModel);
-
-                if (defValue != null) {
-                    String sValue = vp.toSerializableString(defValue);
-                    if (sValue != null) vpModel.setDefault(sValue);
-                }
-
-                if (mapping instanceof PassthroughMapping<?, ?>) {
-                    PassthroughMapping<K, V> pm = (PassthroughMapping<K, V>) 
mapping;
-                    AttributeType attrType = 
toAttributeType(pm.getMappingAttributeType());
-
-                    org.cytoscape.view.vizmap.model.PassthroughMapping pmModel 
= new org.cytoscape.view.vizmap.model.PassthroughMapping();
-                    pmModel.setAttributeName(pm.getMappingAttributeName());
-                    pmModel.setAttributeType(attrType);
-
-                    vpModel.setPassthroughMapping(pmModel);
-
-                } else if (mapping instanceof DiscreteMapping<?, ?>) {
-                    DiscreteMapping<K, V> dm = (DiscreteMapping<K, V>) mapping;
-                    AttributeType attrType = 
toAttributeType(dm.getMappingAttributeType());
-
-                    org.cytoscape.view.vizmap.model.DiscreteMapping dmModel = 
new org.cytoscape.view.vizmap.model.DiscreteMapping();
-                    dmModel.setAttributeName(dm.getMappingAttributeName());
-                    dmModel.setAttributeType(attrType);
-
-                    Map<K, V> map = dm.getAll();
-
-                    for (Map.Entry<?, V> entry : map.entrySet()) {
-                        DiscreteMappingEntry entryModel = new 
DiscreteMappingEntry();
-                        
entryModel.setAttributeValue(entry.getKey().toString());
-                        
entryModel.setValue(vp.toSerializableString(entry.getValue()));
-
-                        dmModel.getDiscreteMappingEntry().add(entryModel);
-                    }
-
-                    vpModel.setDiscreteMapping(dmModel);
-
-                } else if (mapping instanceof ContinuousMapping<?, ?>) {
-                    ContinuousMapping<K, V> cm = (ContinuousMapping<K, V>) 
mapping;
-                    AttributeType attrType = 
toAttributeType(cm.getMappingAttributeType());
-
-                    org.cytoscape.view.vizmap.model.ContinuousMapping cmModel 
= new org.cytoscape.view.vizmap.model.ContinuousMapping();
-                    cmModel.setAttributeName(cm.getMappingAttributeName());
-                    cmModel.setAttributeType(attrType);
-
-                    List<ContinuousMappingPoint<K, V>> points = 
cm.getAllPoints();
-
-                    for (ContinuousMappingPoint<K, V> p : points) {
-                        org.cytoscape.view.vizmap.model.ContinuousMappingPoint 
pModel = new org.cytoscape.view.vizmap.model.ContinuousMappingPoint();
-                        
-                        String sValue = p.getValue().toString();
-                        BigDecimal value = new BigDecimal(sValue);
-                        V lesser = p.getRange().lesserValue;
-                        V equal = p.getRange().equalValue;
-                        V greater = p.getRange().greaterValue;
-                        
-                        pModel.setAttrValue(value);
-                        pModel.setLesserValue(vp.toSerializableString(lesser));
-                        pModel.setEqualValue(vp.toSerializableString(equal));
-                        
pModel.setGreaterValue(vp.toSerializableString(greater));
-                        
-                        cmModel.getContinuousMappingPoint().add(pModel);
-                    }
-                    
-                    vpModel.setContinuousMapping(cmModel);
-                }
-            }
-        }
-    }
-
-    private <K, V> void createVisualProperties(VisualStyle vs,
-                                               Class<? extends CyTableEntry> 
targetType,
-                                               
List<org.cytoscape.view.vizmap.model.VisualProperty> vpModelList) {
-        for (org.cytoscape.view.vizmap.model.VisualProperty vpModel : 
vpModelList) {
-            String vpId = vpModel.getName();
-            String defValue = vpModel.getDefault();
-
-            VisualProperty<V> vp = (VisualProperty<V>) 
lexicon.lookup(targetType, vpId);
-
-            if (vp != null) {
-                // Default Value
-                if (defValue != null) {
-                    V value = parseValue(defValue, vp);
-                    vs.setDefaultValue(vp, value);
-
-                    // TODO: dependencies
-                }
-
-                // Any mapping?
-                if (vpModel.getPassthroughMapping() != null) {
-                    org.cytoscape.view.vizmap.model.PassthroughMapping pmModel 
= vpModel.getPassthroughMapping();
-                    String attrName = pmModel.getAttributeName();
-
-                    try {
-                        PassthroughMapping<K, V> pm = (PassthroughMapping<K, 
V>) passthroughMappingFactory
-                                .createVisualMappingFunction(attrName, 
String.class, vp);
-
-                        vs.addVisualMappingFunction(pm);
-
-                    } catch (Exception e) {
-                        logger.error("Cannot create PassthroughMapping 
(style=" + vs.getTitle() + ", property=" +
-                                     vp.getIdString() + ")", e);
-                    }
-                } else if (vpModel.getDiscreteMapping() != null) {
-                    org.cytoscape.view.vizmap.model.DiscreteMapping dmModel = 
vpModel.getDiscreteMapping();
-                    String attrName = dmModel.getAttributeName();
-                    AttributeType attrType = dmModel.getAttributeType();
-
-                    try {
-                        Class<?> attrClass = null;
-
-                        switch (attrType) {
-                            case BOOLEAN:
-                                attrClass = Boolean.class;
-                                break;
-                            case DECIMAL:
-                                attrClass = Double.class;
-                                break;
-                            case INT:
-                                // TODO: what about Long attrs?
-                                attrClass = Integer.class;
-                                break;
-                            default:
-                                attrClass = String.class;
-                                break;
-                        }
-
-                        DiscreteMapping<K, V> dm = (DiscreteMapping<K, V>) 
discreteMappingFactory
-                                .createVisualMappingFunction(attrName, 
attrClass, vp);
-
-                        for (DiscreteMappingEntry entryModel : 
dmModel.getDiscreteMappingEntry()) {
-                            String sAttrValue = entryModel.getAttributeValue();
-                            String sValue = entryModel.getValue();
-
-                            if (sAttrValue != null && sValue != null) {
-                                Object attrValue = null;
-
-                                switch (attrType) {
-                                    case BOOLEAN:
-                                        attrValue = 
Boolean.parseBoolean(sAttrValue);
-                                        break;
-                                    case DECIMAL:
-                                        attrValue = 
Double.parseDouble(sAttrValue);
-                                        break;
-                                    case INT:
-                                        // TODO: what if it is a Long?
-                                        attrValue = 
Integer.parseInt(sAttrValue);
-                                        break;
-                                    default:
-                                        // Note: Always handle List type as 
String!
-                                        attrValue = sAttrValue;
-                                        break;
-                                }
-
-                                V vpValue = parseValue(sValue, vp);
-                                if (vpValue != null) dm.putMapValue((K) 
attrValue, vpValue);
-                            }
-                        }
-
-                        vs.addVisualMappingFunction(dm);
-
-                    } catch (Exception e) {
-                        logger.error("Cannot create DiscreteMapping (style=" + 
vs.getTitle() + ", property=" +
-                                     vp.getIdString() + ")", e);
-                    }
-                } else if (vpModel.getContinuousMapping() != null) {
-                    org.cytoscape.view.vizmap.model.ContinuousMapping cmModel 
= vpModel.getContinuousMapping();
-                    String attrName = cmModel.getAttributeName();
-
-                    try {
-                        ContinuousMapping<K, V> cm = (ContinuousMapping<K, V>) 
continuousMappingFactory
-                                .createVisualMappingFunction(attrName, 
Number.class, vp);
-
-                        for 
(org.cytoscape.view.vizmap.model.ContinuousMappingPoint pModel : cmModel
-                                .getContinuousMappingPoint()) {
-
-                            // Should be numbers or colors
-                            V lesser = parseValue(pModel.getLesserValue(), vp);
-                            V equal = parseValue(pModel.getEqualValue(), vp);
-                            V greater = parseValue(pModel.getGreaterValue(), 
vp);
-
-                            BoundaryRangeValues<V> brv = new 
BoundaryRangeValues<V>(lesser, equal, greater);
-                            Double attrValue = 
pModel.getAttrValue().doubleValue();
-
-                            cm.addPoint((K) attrValue, brv);
-                        }
-
-                        vs.addVisualMappingFunction(cm);
-                    } catch (Exception e) {
-                        logger.error("Cannot create ContinuousMapping (style=" 
+ vs.getTitle() + ", property=" +
-                                     vp.getIdString() + ")", e);
-                    }
-                }
-            }
-        }
-    }
-
-    private void setDependency(VisualLexicon lexicon, VisualStyle vs, String 
key, String value) {
-        // FIXME: should not be global, but per Visual Style
-        if (key.contains("nodeSizeLocked")) {
-            boolean b = Boolean.parseBoolean(value);
-            
lexicon.getVisualLexiconNode(MinimalVisualLexicon.NODE_WIDTH).setDependency(b);
-            
lexicon.getVisualLexiconNode(MinimalVisualLexicon.NODE_HEIGHT).setDependency(b);
-        }
-    }
-
-    public <V> V parseValue(String sValue, VisualProperty<V> vp) {
-        V value = null;
-
-        if (sValue != null && vp != null) {
-            value = vp.parseSerializableString(sValue);
-        }
-
-        return value;
-    }
-
-    private static AttributeType toAttributeType(Class<?> attrClass) {
-        AttributeType attrType = AttributeType.STRING;
-
-        if (attrClass == Boolean.class) {
-            attrType = AttributeType.BOOLEAN;
-        } else if (attrClass == Byte.class || attrClass == Short.class || 
attrClass == Integer.class ||
-                   attrClass == Long.class) {
-            attrType = AttributeType.INT;
-        } else if (Number.class.isAssignableFrom(attrClass)) {
-            attrType = AttributeType.DECIMAL;
-        }
-
-        return attrType;
-    }
-}

Modified: 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-06-13 15:46:12 UTC (rev 25720)
+++ 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-06-13 16:07:49 UTC (rev 25721)
@@ -16,11 +16,6 @@
                interface="org.cytoscape.view.vizmap.VisualStyleFactory">
        </osgi:service>
 
-       <!-- Export Visual Style Serializer as an OSGi Service -->
-       <osgi:service id="visualStyleSerializerService" 
ref="visualStyleSerializer"
-               interface="org.cytoscape.view.vizmap.VisualStyleSerializer">
-       </osgi:service>
-
        <!-- Import Services -->
        <osgi:reference id="cyEventHelperServiceRef" 
interface="org.cytoscape.event.CyEventHelper" />
 
@@ -34,14 +29,4 @@
                        unbind-method="removeRenderingEngineFactory" 
ref="visualLexiconManager" />
        </osgi:set>
 
-       <osgi:reference id="discreteMappingFactoryServiceRef"
-               
interface="org.cytoscape.view.vizmap.VisualMappingFunctionFactory"
-               filter="(mapping.type=discrete)" />
-       <osgi:reference id="continuousMappingFactoryServiceRef"
-               
interface="org.cytoscape.view.vizmap.VisualMappingFunctionFactory"
-               filter="(mapping.type=continuous)" />
-       <osgi:reference id="passthroughMappingFactoryServiceRef"
-               
interface="org.cytoscape.view.vizmap.VisualMappingFunctionFactory"
-               filter="(mapping.type=passthrough)" />
-
 </beans>

Modified: 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
  2011-06-13 15:46:12 UTC (rev 25720)
+++ 
core3/vizmap-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
  2011-06-13 16:07:49 UTC (rev 25721)
@@ -31,15 +31,5 @@
                <constructor-arg ref="visualStyleFactory" />
                <constructor-arg ref="visualLexiconManager" />
        </bean>
-       
-       <bean id="visualStyleSerializer"
-               
class="org.cytoscape.view.vizmap.internal.VisualStyleSerializerImpl">
-               <constructor-arg ref="visualStyleFactory" />
-               <constructor-arg ref="visualMappingManager" />
-               <constructor-arg ref="renderingEngineManagerServiceRef" />
-               <constructor-arg ref="discreteMappingFactoryServiceRef" />
-        <constructor-arg ref="continuousMappingFactoryServiceRef" />
-        <constructor-arg ref="passthroughMappingFactoryServiceRef" />
-       </bean>
 
 </beans>

Deleted: 
core3/vizmap-impl/trunk/impl/src/test/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerTest.java
===================================================================
--- 
core3/vizmap-impl/trunk/impl/src/test/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerTest.java
        2011-06-13 15:46:12 UTC (rev 25720)
+++ 
core3/vizmap-impl/trunk/impl/src/test/java/org/cytoscape/view/vizmap/internal/VisualStyleSerializerTest.java
        2011-06-13 16:07:49 UTC (rev 25721)
@@ -1,315 +0,0 @@
-package org.cytoscape.view.vizmap.internal;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.presentation.RenderingEngineManager;
-import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
-import org.cytoscape.view.presentation.property.NullVisualProperty;
-import org.cytoscape.view.vizmap.AbstractVisualStyleSerializerTest;
-import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
-import org.cytoscape.view.vizmap.VisualMappingManager;
-import org.cytoscape.view.vizmap.VisualStyle;
-import org.cytoscape.view.vizmap.VisualStyleFactory;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-public class VisualStyleSerializerTest extends 
AbstractVisualStyleSerializerTest {
-
-    Map<VisualStyle, String> styleNames;
-    Map<VisualStyle, Map<VisualProperty<?>, ?>> styleProperties;
-
-    @Before
-    public void setUp() throws Exception {
-        styleNames = new Hashtable<VisualStyle, String>();
-        styleProperties = new Hashtable<VisualStyle, Map<VisualProperty<?>, ? 
extends Object>>();
-
-        final VisualMappingManager visualMappingManager = 
mock(VisualMappingManager.class);
-        final VisualMappingFunctionFactory discreteMappingFactory = 
mock(VisualMappingFunctionFactory.class);
-        final VisualMappingFunctionFactory continuousMappingFactory = 
mock(VisualMappingFunctionFactory.class);
-        final VisualMappingFunctionFactory passthroughMappingFactory = 
mock(VisualMappingFunctionFactory.class);
-        final VisualStyle dummyDefaultStyle = createDefaultStyle();
-
-        final VisualStyleFactory visualStyleFactory = 
mock(VisualStyleFactory.class);
-
-        
when(visualMappingManager.getDefaultVisualStyle()).thenReturn(dummyDefaultStyle);
-        when(visualStyleFactory.getInstance(dummyDefaultStyle)).thenAnswer(new 
Answer<VisualStyle>() {
-
-            public VisualStyle answer(InvocationOnMock invocation) throws 
Throwable {
-                return createDefaultStyle();
-            }
-        });
-
-        final RenderingEngineManager renderingEngineManager = 
mock(RenderingEngineManager.class);
-        NullVisualProperty twoDRoot = new NullVisualProperty("TWO_D_ROOT", "2D 
Root Visual Property");
-        when(renderingEngineManager.getDefaultVisualLexicon()).thenReturn(new 
MinimalVisualLexicon(twoDRoot));
-
-        serializer = new VisualStyleSerializerImpl(visualStyleFactory, 
visualMappingManager, renderingEngineManager,
-                                                   discreteMappingFactory, 
continuousMappingFactory,
-                                                   passthroughMappingFactory);
-    }
-
-    @Test
-    public void tesCreateVisualStyles() throws Exception {
-        // TODO
-//        Properties props = new Properties();
-//        // Style A:
-//        props.setProperty("globalAppearanceCalculator.Style 
A.defaultBackgroundColor", "255,255,255");
-//        props.setProperty("edgeAppearanceCalculator.Style 
A.defaultEdgeLineWidth", "2.0");
-//        // Style B:
-//        props.setProperty("globalAppearanceCalculator.Style 
B.defaultBackgroundColor", "0,255,0");
-//        // Should IGNORE this:
-//        props.setProperty("nodeLabelCalculator.Style C-Node 
Label-Passthrough Mapper.mapping.controller", "ID");
-//
-//        // TEST:
-//        Collection<VisualStyle> styles = 
serializer.createVisualStyles(props);
-//
-//        assertEquals(2, styles.size());
-//
-//        for (VisualStyle vs : styles) {
-//            String title = vs.getTitle();
-//            assertTrue(title.equals(styleNames.get(vs)));
-//
-//            if (title.equals("Style A")) {
-//                //                assertEquals(new Color(255, 255, 255), 
vs.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
-//                //                assertEquals(new Double(2), 
vs.getDefaultValue(TwoDVisualLexicon.EDGE_WIDTH));
-//            } else if (title.equals("Style B")) {
-//                //                assertEquals(new Color(0, 255, 0), 
vs.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
-//            }
-//        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private VisualStyle createDefaultStyle() {
-        final VisualStyle vs = mock(VisualStyle.class);
-
-        // stub get/setTitle
-        doAnswer(new Answer<Void>() {
-
-            public Void answer(InvocationOnMock invocation) {
-                Object[] args = invocation.getArguments();
-                styleNames.put(vs, (String) args[0]);
-                return null;
-            }
-        }).when(vs).setTitle(anyString());
-
-        when(vs.getTitle()).thenAnswer(new Answer<String>() {
-
-            public String answer(InvocationOnMock invocation) throws Throwable 
{
-                return styleNames.get(vs);
-            }
-        });
-
-        // stub get/set default values
-        doAnswer(new Answer<Void>() {
-
-            public Void answer(InvocationOnMock invocation) {
-                Object[] args = invocation.getArguments();
-                VisualProperty<?> vp = (VisualProperty) args[0];
-                Object val = args[1];
-
-                Map vpMap = styleProperties.get(vs);
-                if (vpMap == null) {
-                    vpMap = new Hashtable();
-                    styleProperties.put(vs, vpMap);
-                }
-
-                vpMap.put(vp, val);
-
-                return null;
-            }
-        }).when(vs).setDefaultValue(any(VisualProperty.class), anyObject());
-
-        when(vs.getDefaultValue(any(VisualProperty.class))).thenAnswer(new 
Answer<Object>() {
-
-            public Object answer(InvocationOnMock invocation) throws Throwable 
{
-                Object val = null;
-                Object[] args = invocation.getArguments();
-                VisualProperty<?> vp = (VisualProperty) args[0];
-
-                if (vp != null) {
-                    Map vpMap = styleProperties.get(vs);
-                    if (vpMap != null) val = vpMap.get(vp);
-                }
-
-                return val;
-            }
-        });
-
-        return vs;
-    }
-
-    //    @Test
-    //    public void convertOldProperty() {
-    //        Map<String, String> m;
-    //        Properties p = new Properties();
-    //        
-    //        // Default properties ------------
-    //        // Edge - LineType
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeLineType",
 "LINE_1", p);
-    //        assertEquals("SOLID", 
m.get("edgeAppearanceCalculator.a.defaultEdgeLineStyle"));
-    //        assertEquals("1", 
m.get("edgeAppearanceCalculator.a.defaultEdgeLineWidth"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeLineType",
 "DASHED_3", p);
-    //        assertEquals("EQUAL_DASH", 
m.get("edgeAppearanceCalculator.a.defaultEdgeLineStyle"));
-    //        assertEquals("3", 
m.get("edgeAppearanceCalculator.a.defaultEdgeLineWidth"));
-    //        
-    //        // Node - LineType
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("nodeAppearanceCalculator.a.defaultNodeLineType",
 "LINE_7", p);
-    //        assertEquals("SOLID", 
m.get("nodeAppearanceCalculator.a.defaultNodeLineStyle"));
-    //        assertEquals("7", 
m.get("nodeAppearanceCalculator.a.defaultNodeLineWidth"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("nodeAppearanceCalculator.a.defaultNodeLineType",
 "DASHED_5", p);
-    //        assertEquals("EQUAL_DASH", 
m.get("nodeAppearanceCalculator.a.defaultNodeLineStyle"));
-    //        assertEquals("5", 
m.get("nodeAppearanceCalculator.a.defaultNodeLineWidth"));
-    //        
-    //        // Edge - Arrow
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeSourceArrow",
 "NONE", p);
-    //        assertEquals("NONE", 
m.get("edgeAppearanceCalculator.a.defaultEdgeSourceArrowShape"));
-    //        
assertNull(m.get("edgeAppearanceCalculator.a.defaultEdgeTargetArrowColor"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeTargetArrow",
 "COLOR_DIAMOND", p);
-    //        assertEquals("DIAMOND", 
m.get("edgeAppearanceCalculator.a.defaultEdgeTargetArrowShape"));
-    //        
assertNull(m.get("edgeAppearanceCalculator.a.defaultEdgeTargetArrowColor"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeSourceArrow",
 "WHITE_DELTA", p);
-    //        assertEquals("DELTA", 
m.get("edgeAppearanceCalculator.a.defaultEdgeSourceArrowShape"));
-    //        assertEquals("255,255,255", 
m.get("edgeAppearanceCalculator.a.defaultEdgeSourceArrowColor"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("edgeAppearanceCalculator.a.defaultEdgeTargetArrow",
 "BLACK_CIRCLE", p);
-    //        assertEquals("CIRCLE", 
m.get("edgeAppearanceCalculator.a.defaultEdgeTargetArrowShape"));
-    //        assertEquals("0,0,0", 
m.get("edgeAppearanceCalculator.a.defaultEdgeTargetArrowColor"));
-    //        
-    //        // No changes required
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("nodeAppearanceCalculator.a.defaultNodeShape",
 "rect", p);
-    //        assertEquals("rect", 
m.get("nodeAppearanceCalculator.a.defaultNodeShape"));
-    //        
-    //        m = 
VisualStyleSerializerImpl.updateOldProperty("nodeUniformSizeCalculator.Node 
Size-Continuous Mapper.mapping.boundaryvalues", "1", p);
-    //        assertEquals("1", m.get("nodeUniformSizeCalculator.Node 
Size-Continuous Mapper.mapping.boundaryvalues"));
-    //    }
-
-    @Test
-    public void testGetStyleName() {
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("globalAppearanceCalculator.My 
style.defaultBackgroundColor"));
-//        assertEquals("My style 2", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My style 
2.defaultNodeBorderColor"));
-//        assertEquals("default", VisualStyleSerializerImpl
-//                
.getStyleName("edgeAppearanceCalculator.default.defaultEdgeToolTip"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My 
style.nodeLabelCalculator"));
-//        assertEquals("default", VisualStyleSerializerImpl
-//                
.getStyleName("nodeAppearanceCalculator.default.defaultNodeCustomGraphics1"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My 
style.nodeSizeLocked"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My 
style.defaultNodeShowNestedNetworks"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My 
style.nodeLabelColorFromNodeColor"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("nodeAppearanceCalculator.My 
style.nodeCustomGraphicsSizeSync"));
-//        assertEquals("My style", VisualStyleSerializerImpl
-//                .getStyleName("edgeAppearanceCalculator.My 
style.arrowColorMatchesEdge"));
-//
-//        assertNull(VisualStyleSerializerImpl
-//                .getStyleName("nodeBorderColorCalculator.My style-Node 
Border Color-Discrete Mapper.mapping.map.A03"));
-//        assertNull(VisualStyleSerializerImpl
-//                .getStyleName("edgeColorCalculator.default-Edge 
Color-Continuous Mapper.mapping.boundaryvalues=2"));
-    }
-//
-//    @Test
-//    public void testIsDefaultProperty() {
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("globalAppearanceCalculator.My 
style.defaultBackgroundColor"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("globalAppearanceCalculator.My 
style.defaultNodeSelectionColor"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("globalAppearanceCalculator.My 
style.defaultEdgeReverseSelectionColor"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeBorderColor"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeBorderOpacity"));
-//        
assertTrue(VisualStyleSerializerImpl.isDefaultProperty("nodeAppearanceCalculator.default.defaultNodeFont"));
-//        
assertTrue(VisualStyleSerializerImpl.isDefaultProperty("nodeAppearanceCalculator.My
 style.defaultNodeHight"));
-//        
assertTrue(VisualStyleSerializerImpl.isDefaultProperty("nodeAppearanceCalculator.My
 style.defaultNodeLabel"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeLineStyle"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeCustomGraphics1"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeCustomGraphicsPosition8"));
-//        
assertTrue(VisualStyleSerializerImpl.isDefaultProperty("edgeAppearanceCalculator.My
 style.defaultEdgeToolTip"));
-//        assertTrue(VisualStyleSerializerImpl
-//                
.isDefaultProperty("edgeAppearanceCalculator.default.defaultEdgeTargetArrowColor"));
-//
-//        assertFalse(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.nodeLabelCalculator"));
-//        
assertFalse(VisualStyleSerializerImpl.isDefaultProperty("nodeAppearanceCalculator.My
 style.nodeSizeLocked"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isDefaultProperty("nodeAppearanceCalculator.My 
style.defaultNodeShowNestedNetwork"));
-//        
assertFalse(VisualStyleSerializerImpl.isDefaultProperty("edgeAppearanceCalculator.default.defaultNodeSize"));
-//        
assertFalse(VisualStyleSerializerImpl.isDefaultProperty("nodeAppearanceCalculator.default.defaultEdgeColor"));
-//    }
-//
-//    @Test
-//    public void testIsMappingFunction() {
-//        
assertTrue(VisualStyleSerializerImpl.isMappingFunction("nodeAppearanceCalculator.My
 style.nodeLabelCalculator"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.nodeBorderColorCalculator"));
-//        
assertTrue(VisualStyleSerializerImpl.isMappingFunction("nodeAppearanceCalculator.My
 style.nodeCustomGraphics1"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.nodeCustomGraphicsPosition4"));
-//        
assertTrue(VisualStyleSerializerImpl.isMappingFunction("edgeAppearanceCalculator.default.edgeColorCalculator"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.galFiltered 
Style.nodeLabelColor"));
-//
-//        
assertFalse(VisualStyleSerializerImpl.isMappingFunction("nodeAppearanceCalculator.My
 style.nodeSizeLocked"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.defaultNodeShowNestedNetwork"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.nodeCustomGraphicsSizeSync"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.nodeLabelColorFromNodeColor"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.defaultNodeCustomGraphics1"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeAppearanceCalculator.My 
style.defaultNodeCustomGraphicsPosition2"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("globalAppearanceCalculator.My 
style.defaultBackgroundColor"));
-//        
assertFalse(VisualStyleSerializerImpl.isMappingFunction("edgeAppearanceCalculator.default.defaultEdgeColor"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isMappingFunction("nodeBorderColorCalculator.My Style-Node 
Border Color-Discrete Mapper.mapping.controller"));
-//    }
-//
-//    @Test
-//    public void testIsDependency() {
-//        
assertTrue(VisualStyleSerializerImpl.isDependency("nodeAppearanceCalculator.My 
style.nodeSizeLocked"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDependency("nodeAppearanceCalculator.My 
style.defaultNodeShowNestedNetwork"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDependency("nodeAppearanceCalculator.My 
style.nodeLabelColorFromNodeColor"));
-//        assertTrue(VisualStyleSerializerImpl
-//                .isDependency("nodeAppearanceCalculator.My 
style.nodeCustomGraphicsSizeSync"));
-//        
assertTrue(VisualStyleSerializerImpl.isDependency("edgeAppearanceCalculator.My 
style.arrowColorMatchesEdge"));
-//
-//        assertFalse(VisualStyleSerializerImpl
-//                .isDependency("globalAppearanceCalculator.My 
style.defaultBackgroundColor"));
-//        
assertFalse(VisualStyleSerializerImpl.isDependency("nodeAppearanceCalculator.My 
style.nodeCustomGraphics1"));
-//        assertFalse(VisualStyleSerializerImpl
-//                .isDependency("nodeAppearanceCalculator.My 
style.nodeCustomGraphicsPosition4"));
-//        assertFalse(VisualStyleSerializerImpl
-//                
.isDependency("nodeAppearanceCalculator.nodeCustomGraphicsSizeSync.defaultNodeCustomGraphicsPosition2"));
-//        assertFalse(VisualStyleSerializerImpl
-//                
.isMappingFunction("nodeBorderColorCalculator.nodeCustomGraphicsSizeSync-Node 
Border Color-Discrete Mapper.mapping.controller"));
-//    }
-}

Modified: core3/vizmap-impl/trunk/it/pom.xml
===================================================================
--- core3/vizmap-impl/trunk/it/pom.xml  2011-06-13 15:46:12 UTC (rev 25720)
+++ core3/vizmap-impl/trunk/it/pom.xml  2011-06-13 16:07:49 UTC (rev 25721)
@@ -4,7 +4,7 @@
        <parent>
                <artifactId>vizmap-impl-parent</artifactId>
                <groupId>org.cytoscape</groupId>
-               <version>3.0.0-alpha4-SNAPSHOT</version>
+               <version>3.0.0-alpha5-SNAPSHOT</version>
        </parent>
 
        <properties>

Modified: 
core3/vizmap-impl/trunk/it/src/test/java/org/cytoscape/view/vizmap/ServiceConfigurationTest.java
===================================================================
--- 
core3/vizmap-impl/trunk/it/src/test/java/org/cytoscape/view/vizmap/ServiceConfigurationTest.java
    2011-06-13 15:46:12 UTC (rev 25720)
+++ 
core3/vizmap-impl/trunk/it/src/test/java/org/cytoscape/view/vizmap/ServiceConfigurationTest.java
    2011-06-13 16:07:49 UTC (rev 25721)
@@ -1,19 +1,15 @@
 package org.cytoscape.view.vizmap; 
 
-import static org.junit.Assert.*;
-import org.junit.Test;
+import java.util.Properties;
+
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.integration.ServiceTestSupport;
+import org.cytoscape.view.presentation.RenderingEngineManager;
 import org.junit.Before;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 
-import org.cytoscape.integration.ServiceTestSupport;
-
-import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.view.presentation.RenderingEngineManager;
-import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
-
-import java.util.Properties;
-
 @RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class ServiceConfigurationTest extends ServiceTestSupport {
 
@@ -39,6 +35,5 @@
        public void testExpectedServices() {
                checkService(VisualMappingManager.class);
                checkService(VisualStyleFactory.class);
-               checkService(VisualStyleSerializer.class);
        }
 }

Modified: core3/vizmap-impl/trunk/pom.xml
===================================================================
--- core3/vizmap-impl/trunk/pom.xml     2011-06-13 15:46:12 UTC (rev 25720)
+++ core3/vizmap-impl/trunk/pom.xml     2011-06-13 16:07:49 UTC (rev 25721)
@@ -10,11 +10,11 @@
        <groupId>org.cytoscape</groupId>
        <artifactId>vizmap-impl-parent</artifactId>
        <packaging>pom</packaging>
-       <version>3.0.0-alpha4-SNAPSHOT</version>
+       <version>3.0.0-alpha5-SNAPSHOT</version>
        <name>vizmap-impl-parent</name>
        
        <properties>
-               <vizmap-api.version>3.0.0-alpha5-SNAPSHOT</vizmap-api.version>
+               <vizmap-api.version>3.0.0-alpha6-SNAPSHOT</vizmap-api.version>
        </properties>
 
        <modules>

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